You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a parametrized test of which one of the invocations uses a (fairly long) byte string as input.
Because pytest tries to print parametrized tests in the most useful way, this byte string ends up in the full test name, which pytest-profiling then uses for the file with the profiling results. This causes an issue on Windows which (unfortunately) has a fairly short file name length limit:
pytest --profile
============================= test session starts =============================
platform win32 -- Python 3.7.3, pytest-5.1.0, py-1.8.0, pluggy-0.12.0
rootdir: C:\Software\tryout\pytest_tryouts
plugins: cov-2.7.1, ordering-0.6, profiling-1.7.0, pycharm-0.6.0
collected 1 item
test_foo.py . [100%]
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\_pytest\main.py", line 191, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\_pytest\main.py", line 235, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\_pytest\main.py", line 256, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pluggy\callers.py", line 203, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\site-packages\pytest_profiling.py", line 80, in pytest_runtest_protocol
INTERNALERROR> prof.dump_stats(prof_filename)
INTERNALERROR> File "c:\users\rnd10\appdata\local\programs\python\python37-32\lib\cProfile.py", line 46, in dump_stats
INTERNALERROR> with open(file, 'wb') as f:
INTERNALERROR> OSError: [Errno 22] Invalid argument: 'C:\\Software\\tryout\\pytest_tryouts\\prof\\test_foo[_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff_xff].prof'
============================== 1 passed in 0.02s ==============================
Is this something pytest-profiling could handle in some way? It would be a pity if I could not write tests like this one and profile them 🤔
The text was updated successfully, but these errors were encountered:
I have a parametrized test of which one of the invocations uses a (fairly long) byte string as input.
Because pytest tries to print parametrized tests in the most useful way, this byte string ends up in the full test name, which pytest-profiling then uses for the file with the profiling results. This causes an issue on Windows which (unfortunately) has a fairly short file name length limit:
Is this something pytest-profiling could handle in some way? It would be a pity if I could not write tests like this one and profile them 🤔
The text was updated successfully, but these errors were encountered: