gruns / icecream

🍦 Never use print() to debug again.
MIT License
8.92k stars 184 forks source link

2.1.3: pytest is failing in two nits #144

Open kloczek opened 1 year ago

kloczek commented 1 year ago

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-icecream-2.1.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-icecream-2.1.3-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/icecream-2.1.3 collected 37 items tests/test_icecream.py ..........F.....................F.. [ 94%] tests/test_install.py .. [100%] ========================================================================================= FAILURES ========================================================================================== ______________________________________________________________________________ TestIceCream.testEnableDisable _______________________________________________________________________________ self = def testEnableDisable(self): with disableColoring(), captureStandardStreams() as (out, err): assert ic(a) == 1 assert ic.enabled ic.disable() assert not ic.enabled assert ic(b) == 2 ic.enable() assert ic.enabled assert ic(c) == 3 pairs = parseOutputIntoPairs(out, err, 2) > assert pairs == [[('a', '1')], [('c', '3')]] E AssertionError: assert [[('REPL (e.g...ion?', None)]] == [[('a', '1')], [('c', '3')]] E At index 0 diff: [('REPL (e.g. from the command line), a frozen application (e.g. packaged with PyInstaller), or did the underlying source code change during execution?', None)] != [('a', '1')] E Use -v to get more diff tests/test_icecream.py:380: AssertionError ______________________________________________________________________ TestIceCream.testSingledispatchArgumentToString ______________________________________________________________________ self = def testSingledispatchArgumentToString(self): def argumentToString_tuple(obj): return "Dispatching tuple!" # Unsupport Python2 if "singledispatch" not in dir(functools): for attr in ("register", "unregister"): with self.assertRaises(NotImplementedError): getattr(argumentToString, attr)( tuple, argumentToString_tuple ) return # Prepare input and output x = (1, 2) default_output = ic.format(x) # Register argumentToString.register(tuple, argumentToString_tuple) assert tuple in argumentToString.registry > assert str.endswith(ic.format(x), argumentToString_tuple(x)) tests/test_icecream.py:413: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../BUILDROOT/python-icecream-2.1.3-2.fc35.x86_64/usr/lib/python3.8/site-packages/icecream/icecream.py:225: in format out = self._format(callFrame, *args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = callFrame = , args = ((1, 2),) prefix = 'ic| ', callNode = None def _format(self, callFrame, *args): prefix = callOrValue(self.prefix) callNode = Source.executing(callFrame).node if callNode is None: > raise NoSourceAvailableError() E icecream.icecream.NoSourceAvailableError ../../BUILDROOT/python-icecream-2.1.3-2.fc35.x86_64/usr/lib/python3.8/site-packages/icecream/icecream.py:233: NoSourceAvailableError ===================================================================================== warnings summary ====================================================================================== tests/test_icecream.py::TestIceCream::testMultilineContainerArgs /home/tkloczko/rpmbuild/BUILD/icecream-2.1.3/tests/test_icecream.py:573: DeprecationWarning: Please use assertRegex instead. self.assertRegexpMatches( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ================================================================================== short test summary info ================================================================================== FAILED tests/test_icecream.py::TestIceCream::testEnableDisable - AssertionError: assert [[('REPL (e.g...ion?', None)]] == [[('a', '1')], [('c', '3')]] FAILED tests/test_icecream.py::TestIceCream::testSingledispatchArgumentToString - icecream.icecream.NoSourceAvailableError ========================================================================== 2 failed, 35 passed, 1 warning in 1.35s ========================================================================== ```

Here is list of installed modules in build env

```console Package Version --------------- -------------- asttokens 2.2.1 attrs 22.2.0 build 0.10.0 colorama 0.4.6 distro 1.8.0 exceptiongroup 1.0.0 executing 1.2.0 gpg 1.18.0-unknown iniconfig 2.0.0 libcomps 0.1.19 packaging 23.0 pip 22.3.1 pluggy 1.0.0 Pygments 2.14.0 pyproject_hooks 1.0.0 pytest 7.2.2 python-dateutil 2.8.2 rpm 4.17.0 setuptools 65.6.3 six 1.16.0 tomli 2.0.1 wheel 0.38.4 ```
haorannlp commented 1 year ago

Same problem when testing with py3.8, py3.9