From 7860f47363d2dbf637ef2cbb33860e3e08ba9e3b Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 1 May 2018 17:28:02 +0300 Subject: [PATCH] generate some duplicate code. --- Makefile | 2 +- scripts/gen_individual_importing_tests.py | 13 +++++++++++++ tests/unit-generated/PLACEHOLDER | 0 tests/unit/import_file1.py | 5 ----- tests/unit/import_file1_py3.py | 5 ----- tests/unit/ms_deals1.py | 5 ----- tests/unit/ms_deals1_py3.py | 5 ----- 7 files changed, 14 insertions(+), 21 deletions(-) create mode 100644 tests/unit-generated/PLACEHOLDER delete mode 100644 tests/unit/import_file1.py delete mode 100644 tests/unit/import_file1_py3.py delete mode 100644 tests/unit/ms_deals1.py delete mode 100644 tests/unit/ms_deals1_py3.py diff --git a/Makefile b/Makefile index c6d56687..4a8232a8 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ pretest: python scripts/gen_individual_importing_tests.py TEST_ENV = PYTHONPATH="`pwd`:`pwd`/tests/lib" -TEST_FILES = tests/style/*.t tests/unit/*.py tests/individually-importing/*.py +TEST_FILES = tests/style/*.t tests/unit/*.py tests/unit-generated/*.py tests/individually-importing/*.py define RUN_TESTS $(TEST_ENV) $1 $(TEST_FILES) diff --git a/scripts/gen_individual_importing_tests.py b/scripts/gen_individual_importing_tests.py index f5207ed2..edccc3f4 100644 --- a/scripts/gen_individual_importing_tests.py +++ b/scripts/gen_individual_importing_tests.py @@ -209,3 +209,16 @@ sys.path.insert(0, ".") import %(module_name)s print('ok 1 - imported') ''')) + +for ver in [2, 3]: + for mod in [ + 'pysol_tests.import_file1', + 'pysol_tests.ms_deals1', + ]: + open(os.path.join(".", "tests", "unit-generated", + 'test__%s__v%d.py' % (mod, ver) + ), 'w').write('''#!/usr/bin/env python%(ver)d +from %(mod)s import mymain + +mymain() +''' % {'mod': mod, 'ver': ver}) diff --git a/tests/unit-generated/PLACEHOLDER b/tests/unit-generated/PLACEHOLDER new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/import_file1.py b/tests/unit/import_file1.py deleted file mode 100644 index 08ec28c6..00000000 --- a/tests/unit/import_file1.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python - -from pysol_tests.import_file1 import mymain - -mymain() diff --git a/tests/unit/import_file1_py3.py b/tests/unit/import_file1_py3.py deleted file mode 100644 index c7031e81..00000000 --- a/tests/unit/import_file1_py3.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3 - -from pysol_tests.import_file1 import mymain - -mymain() diff --git a/tests/unit/ms_deals1.py b/tests/unit/ms_deals1.py deleted file mode 100644 index 9c424620..00000000 --- a/tests/unit/ms_deals1.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python - -from pysol_tests.ms_deals1 import mymain - -mymain() diff --git a/tests/unit/ms_deals1_py3.py b/tests/unit/ms_deals1_py3.py deleted file mode 100644 index 7e09fe95..00000000 --- a/tests/unit/ms_deals1_py3.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3 - -from pysol_tests.ms_deals1 import mymain - -mymain()