amyreese / fissix

backport of lib2to3, with enhancements
Other
45 stars 22 forks source link

24.4.24: test suite is packaged into .whl #64

Open kloczek opened 3 months ago

kloczek commented 3 months ago

Looks like fissix/tests is packaged into .whl archive

[tkloczko@pers-jacek fissix-24.4.24]$ unzip -l dist/fissix-24.4.24-py3-none-any.whl | grep tests
        0  04-24-2024 08:08   fissix/tests/__init__.py
       58  04-24-2024 08:08   fissix/tests/__main__.py
     2470  04-24-2024 08:08   fissix/tests/pytree_idempotency.py
     1947  04-24-2024 08:08   fissix/tests/support.py
      596  04-24-2024 08:08   fissix/tests/test_all_fixers.py
   125644  04-24-2024 08:08   fissix/tests/test_fixers.py
     6307  04-24-2024 08:08   fissix/tests/test_main.py
    22604  04-24-2024 08:08   fissix/tests/test_parser.py
    16302  04-24-2024 08:08   fissix/tests/test_pytree.py
    12353  04-24-2024 08:08   fissix/tests/test_refactor.py
    21189  04-24-2024 08:08   fissix/tests/test_util.py
      402  04-24-2024 08:08   fissix/tests/data/README
       37  04-24-2024 08:08   fissix/tests/data/bom.py
       50  04-24-2024 08:08   fissix/tests/data/crlf.py
      231  04-24-2024 08:08   fissix/tests/data/different_encoding.py
       40  04-24-2024 08:08   fissix/tests/data/false_encoding.py
    95775  04-24-2024 08:08   fissix/tests/data/infinite_recursion.py
    33729  04-24-2024 08:08   fissix/tests/data/py2_test_grammar.py
    31245  04-24-2024 08:08   fissix/tests/data/py3_test_grammar.py
       89  04-24-2024 08:08   fissix/tests/data/fixers/bad_order.py
       75  04-24-2024 08:08   fissix/tests/data/fixers/no_fixer_cls.py
       23  04-24-2024 08:08   fissix/tests/data/fixers/parrot_example.py
        0  04-24-2024 08:08   fissix/tests/data/fixers/myfixes/__init__.py
      131  04-24-2024 08:08   fissix/tests/data/fixers/myfixes/fix_explicit.py
      132  04-24-2024 08:08   fissix/tests/data/fixers/myfixes/fix_first.py
      133  04-24-2024 08:08   fissix/tests/data/fixers/myfixes/fix_last.py
      346  04-24-2024 08:08   fissix/tests/data/fixers/myfixes/fix_parrot.py
      135  04-24-2024 08:08   fissix/tests/data/fixers/myfixes/fix_preorder.py

Probably easiest way to fix that will be just move fissix/tests/* to tests/.

kloczek commented 3 months ago

Just tested such migration + below patch

--- a/fissix/tests/support.py
+++ b/fissix/tests/support.py
@@ -14,7 +14,7 @@

 test_dir = os.path.dirname(__file__)
 proj_dir = os.path.normpath(os.path.join(test_dir, ".."))
-grammar_path = os.path.join(test_dir, "..", "Grammar.txt")
+grammar_path = os.path.join(test_dir, "..", "fissix", "Grammar.txt")
 grammar = pgen2_driver.load_grammar(grammar_path)
 grammar_no_print_statement = pgen2_driver.load_grammar(grammar_path)
 del grammar_no_print_statement.keywords["print"]

Applied before move content of fissix/tests to tests/.

Here is result

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-fissix-24.4.24-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-fissix-24.4.24-2.fc37.x86_64/usr/lib/python3.10/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0 rootdir: /home/tkloczko/rpmbuild/BUILD/fissix-24.4.24 configfile: pyproject.toml collected 670 items tests/test_all_fixers.py . [ 0%] tests/test_fixers.py ................................................................................................................................................................ [ 24%] ..................................................................................................................................................................................... [ 51%] ................................................................................................................................. [ 70%] tests/test_main.py xxx. [ 70%] tests/test_parser.py ..x............................................................................................... [ 85%] tests/test_pytree.py .................................... [ 90%] tests/test_refactor.py .................... [ 93%] tests/test_smoke.py . [ 94%] tests/test_util.py ........................................ [100%] ========================================================================================= XFAILURES ========================================================================================= ___________________________________________________________________ TestMain.test_filename_changing_on_output_single_dir ____________________________________________________________________ self = @pytest.mark.xfail def test_filename_changing_on_output_single_dir(self): """2to3 a single directory with a new output dir and suffix.""" self.setup_test_source_trees() out = io.StringIO() err = io.StringIO() suffix = "TEST" ret = self.run_2to3_capture( [ "-n", "--add-suffix", suffix, "--write-unchanged-files", "--no-diffs", "--output-dir", self.py3_dest_dir, self.py2_src_dir, ], io.StringIO(""), out, err, ) self.assertEqual(ret, 0) stderr = err.getvalue() self.assertIn(" implies -w.", stderr) > self.assertIn( "Output in %r will mirror the input directory %r layout" % (self.py3_dest_dir, self.py2_src_dir), stderr, ) E AssertionError: "Output in '/tmp/tmp88ubfhx7/python3_project' will mirror the input directory '/tmp/tmp88ubfhx7/python2_project' layout" not found in 'WARNING: --write-unchanged-files/-W implies -w.\n' tests/test_main.py:103: AssertionError ___________________________________________________________________ TestMain.test_filename_changing_on_output_single_file ___________________________________________________________________ self = @pytest.mark.xfail def test_filename_changing_on_output_single_file(self): """2to3 a single file with a new output dir.""" self.setup_test_source_trees() err = io.StringIO() ret = self.run_2to3_capture( [ "-n", "-w", "--no-diffs", "--output-dir", self.py3_dest_dir, self.trivial_py2_file, ], io.StringIO(""), io.StringIO(), err, ) self.assertEqual(ret, 0) stderr = err.getvalue() > self.assertIn( "Output in %r will mirror the input directory %r layout" % (self.py3_dest_dir, self.py2_src_dir), stderr, ) E AssertionError: "Output in '/tmp/tmpzhvhhyvt/python3_project' will mirror the input directory '/tmp/tmpzhvhhyvt/python2_project' layout" not found in '' tests/test_main.py:175: AssertionError ____________________________________________________________________ TestMain.test_filename_changing_on_output_two_files ____________________________________________________________________ self = @pytest.mark.xfail def test_filename_changing_on_output_two_files(self): """2to3 two files in one directory with a new output dir.""" self.setup_test_source_trees() err = io.StringIO() py2_files = [self.trivial_py2_file, self.init_py2_file] expected_files = set(os.path.basename(name) for name in py2_files) ret = self.run_2to3_capture( [ "-n", "-w", "--write-unchanged-files", "--no-diffs", "--output-dir", self.py3_dest_dir, ] + py2_files, io.StringIO(""), io.StringIO(), err, ) self.assertEqual(ret, 0) stderr = err.getvalue() > self.assertIn( "Output in %r will mirror the input directory %r layout" % (self.py3_dest_dir, self.py2_src_dir), stderr, ) E AssertionError: "Output in '/tmp/tmppx7ncwai/python3_project' will mirror the input directory '/tmp/tmppx7ncwai/python2_project' layout" not found in '' tests/test_main.py:148: AssertionError ____________________________________________________________________ TestPgen2Caching.test_load_grammar_from_subprocess _____________________________________________________________________ self = @pytest.mark.xfail @unittest.skipIf(sys.executable is None, "sys.executable required") def test_load_grammar_from_subprocess(self): tmpdir = tempfile.mkdtemp() tmpsubdir = os.path.join(tmpdir, "subdir") try: os.mkdir(tmpsubdir) grammar_base = os.path.basename(support.grammar_path) grammar_copy = os.path.join(tmpdir, grammar_base) grammar_sub_copy = os.path.join(tmpsubdir, grammar_base) shutil.copy(support.grammar_path, grammar_copy) shutil.copy(support.grammar_path, grammar_sub_copy) pickle_name = pgen2_driver._generate_pickle_name(grammar_copy) pickle_sub_name = pgen2_driver._generate_pickle_name(grammar_sub_copy) > self.assertNotEqual(pickle_name, pickle_sub_name) E AssertionError: '/home/tkloczko/.cache/fissix/24.4.24/Grammar3.9.0a6+.pickle' == '/home/tkloczko/.cache/fissix/24.4.24/Grammar3.9.0a6+.pickle' tests/test_parser.py:77: AssertionError ================================================================================== short test summary info ================================================================================== XFAIL tests/test_main.py::TestMain::test_filename_changing_on_output_single_dir XFAIL tests/test_main.py::TestMain::test_filename_changing_on_output_single_file XFAIL tests/test_main.py::TestMain::test_filename_changing_on_output_two_files XFAIL tests/test_parser.py::TestPgen2Caching::test_load_grammar_from_subprocess ============================================================================== 666 passed, 4 xfailed in 24.91s ============================================================================== ```

Please let me know if you want above changes as PR.