Skip to content

Commit 1e820d0

Browse files
Conchylicultorcopybara-github
authored andcommitted
Internal
PiperOrigin-RevId: 289523403
1 parent 1d77831 commit 1e820d0

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

oss_scripts/oss_tests.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,26 @@ function set_status() {
1818
STATUS=$(($last_status || $STATUS))
1919
}
2020

21+
PY_BIN=$(python -c "import sys; print('python%s' % sys.version[0:3])")
22+
23+
24+
# Certain datasets/tests don't work with Python 2
25+
PY2_IGNORE_TESTS=""
26+
if [[ "$PY_BIN" = "python2.7" ]]
27+
then
28+
PY2_IGNORE_TESTS="
29+
tensorflow_datasets/audio/nsynth_test.py
30+
tensorflow_datasets/text/c4_test.py
31+
tensorflow_datasets/text/c4_utils_test.py
32+
tensorflow_datasets/image/imagenet2012_corrupted_test.py
33+
"
34+
fi
35+
PY2_IGNORE=$(for test in $PY2_IGNORE_TESTS; do echo "--ignore=$test "; done)
36+
37+
2138
# Run Tests
2239
# Ignores:
23-
# * Some TF2 tests if running against TF2 (see above)
40+
# * Some Python2 tests if running against Python2 (see above)
2441
# * Nsynth is run is isolation due to dependency conflict (crepe)
2542
# * Lsun tests is disabled because the tensorflow_io used in open-source
2643
# is linked to static libraries compiled again specific TF version, which
@@ -33,6 +50,7 @@ function set_status() {
3350
pytest \
3451
-n auto \
3552
--disable-warnings \
53+
$PY2_IGNORE \
3654
--ignore="tensorflow_datasets/audio/nsynth_test.py" \
3755
--ignore="tensorflow_datasets/image/lsun_test.py" \
3856
--ignore="tensorflow_datasets/testing/test_utils.py" \
@@ -53,7 +71,6 @@ NOTEBOOKS="
5371
docs/overview.ipynb
5472
docs/_index.ipynb
5573
"
56-
PY_BIN=$(python -c "import sys; print('python%s' % sys.version[0:3])")
5774
function test_notebook() {
5875
local notebook=$1
5976
create_virtualenv tfds_notebook $PY_BIN

tensorflow_datasets/core/lazy_imports_lib_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class LazyImportsTest(testing.TestCase, parameterized.TestCase):
4646
"tldextract",
4747
)
4848
def test_import(self, module_name):
49+
if module_name == "nltk" and six.PY2: # sklearn do not support Python2
50+
return
4951
# TODO(rsepassi): Re-enable skimage on Py3 (b/129964829)
5052
if module_name == "skimage" and six.PY3:
5153
return

0 commit comments

Comments
 (0)