mrabarnett / mrab-regex

Other
436 stars 49 forks source link

2021.7.6: pytest is failing #416

Open mrabarnett opened 3 years ago

mrabarnett commented 3 years ago

Original report by Tomasz Kłoczko (Bitbucket: [Tomasz Kłoczko](https://bitbucket.org/Tomasz Kłoczko), ).


Just normal build, install and test cycle used on building package from non-root account:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-regex-2021.7.6-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-regex-2021.7.6-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/regex-2021.7.6
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, hypothesis-6.14.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, Faker-8.9.0, cases-3.6.2
collected 103 items

. .                                                                                                                                                                  [  0%]
regex_3/test_regex.py ....................................................................................................F                                          [100%]

================================================================================= FAILURES =================================================================================
________________________________________________________________________________ test_main _________________________________________________________________________________

    def test_main():
>       unittest.main(verbosity=2)

regex_3/test_regex.py:4396:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib64/python3.8/unittest/main.py:100: in __init__
    self.parseArgs(argv)
/usr/lib64/python3.8/unittest/main.py:133: in parseArgs
    self._main_parser.parse_args(argv[1:], self)
/usr/lib64/python3.8/argparse.py:1771: in parse_args
    self.error(msg % ' '.join(argv))
/usr/lib64/python3.8/argparse.py:2521: in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = ArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True), status = 2
message = 'pytest: error: unrecognized arguments: -ra\n'

    def exit(self, status=0, message=None):
        if message:
            self._print_message(message, _sys.stderr)
>       _sys.exit(status)
E       SystemExit: 2

/usr/lib64/python3.8/argparse.py:2508: SystemExit
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
usage: pytest [-h] [-v] [-q] [--locals] [-f] [-c] [-b] [-k TESTNAMEPATTERNS]
              [tests [tests ...]]
pytest: error: unrecognized arguments: -ra
========================================================================= short test summary info ==========================================================================
FAILED regex_3/test_regex.py::test_main - SystemExit: 2
====================================================================== 1 failed, 101 passed in 8.28s =======================================================================

mrabarnett commented 3 years ago

Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).


So, you’re using pytest, but giving it an argument it doesn’t understand?

I haven’t used pytest. I use unittest because that’s what the re module uses:

py -3.8 -m unittest -v regex.test_regex

mrabarnett commented 3 years ago

Original comment by Tomasz Kłoczko (Bitbucket: [Tomasz Kłoczko](https://bitbucket.org/Tomasz Kłoczko), ).


On first look it looks like pytest argument is passed to unittest and this is why it fails.

Temporary I’ve added that failing unit in my rpm spec fiels to list of deselected units so no ruch :slight_smile:

BTW you should not use “python -m unittest” beause module executed that way adds upfront to sys.path current directory and $PYTHONPATH will be used only if in curret directory will be no module. Result will be that it will be tested not what has been installed in </install/prefix> but source tree.

mrabarnett commented 3 years ago

Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).


python -m unittest is shown in the “Command-Line Interface” section in the Python docs!

mrabarnett commented 2 years ago

Original comment by Tomasz Kłoczko (Bitbucket: [Tomasz Kłoczko](https://bitbucket.org/Tomasz Kłoczko), ).


“Command-Line Interface”? .. hmm .. what you mean?

Just tested 2021.10.23 and issu estill is around. Thre are some new warnings

PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-regex-2021.10.23-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-regex-2021.10.23-2.fc35.x86_64/usr/lib/python3.8/site-packages

/usr/bin/pytest -ra --deselect regex_3/test_regex.py::test_main
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
rootdir: /home/tkloczko/rpmbuild/BUILD/regex-2021.10.23
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, flake8-1.0.7, xdist-2.3.0, cov-2.12.1, mock-3.6.1, localserver-0.5.0, timeout-2.0.1, flaky-3.7.0, hypothesis-6.14.6, rerunfailures-9.1.1
collected 101 items / 1 deselected / 100 selected

regex_3/test_regex.py .................................................................................................... [100%]

============================================================================= warnings summary =============================================================================
regex_3/test_regex.py:4273
/home/tkloczko/rpmbuild/BUILD/regex-2021.10.23/regex_3/test_regex.py:4273: DeprecationWarning: invalid escape sequence \d
self.assertEqual(regex.compile("(\d+ week|\d+ days)").split("7 days"), ['', '7 days', ''])

regex_3/test_regex.py:4274
/home/tkloczko/rpmbuild/BUILD/regex-2021.10.23/regex_3/test_regex.py:4274: DeprecationWarning: invalid escape sequence \d
self.assertEqual(regex.compile("(\d+ week|\d+ days)").split("10 days"), ['', '10 days', ''])

regex_3/test_regex.py:4276
/home/tkloczko/rpmbuild/BUILD/regex-2021.10.23/regex_3/test_regex.py:4276: DeprecationWarning: invalid escape sequence *
self.assertEqual(regex.compile("[ ]* Name[ ]** ").search(" Name *"), None)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
============================================================== 100 passed, 1 deselected, 3 warnings in 0.64s ===============================================================

mrabarnett commented 2 years ago

Original comment by Matthew Barnett (Bitbucket: mrabarnett, GitHub: mrabarnett).


I’m talking about the Python docs on unittest, and the section titled “Command-Line Interface”.

EpicWink commented 2 months ago

See https://github.com/mrabarnett/mrab-regex/issues/448#issuecomment-2222396902