In my code, I have a line that says something like
print("Some string:", end=" ")
When I try to run pytest, I get the following:
ryansmacbook:scripts ryan$ py.test file.py
============================= test session starts ==============================
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2
collected 0 items / 1 errors
==================================== ERRORS ====================================
________________________ ERROR collecting cpp-allman.py ________________________
/Library/Python/2.7/site-packages/pytest-2.5.2-py2.7.egg/_pytest/python.py:451: in _importtestmodule
> mod = self.fspath.pyimport(ensuresyspath=True)
/Library/Python/2.7/site-packages/py-1.4.20-py2.7.egg/py/_path/local.py:620: in pyimport
> __import__(modname)
E File "/Users/ryan/path/to/file.py", line 65
E "Some string:", end=" ")
E ^
E SyntaxError: invalid syntax
=========================== 1 error in 0.07 seconds ============================
When I comment out the print statement, testing takes forever. I'm trying to test regexes (Testing regexes in Python using py.test), but this is what happens:
ryansmacbook:scripts ryan$ py.test file.py
============================= test session starts ==============================
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2
collecting 0 items^C
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/Users/ryan/magzor/scripts/file.py:134: KeyboardInterrupt
============================= in 2397.55 seconds ==============================
Before I implemented that possible solution, testing took between 30 and 60 seconds, which still seems too long. What's going on?
========================================
Edit: I commented out a part of my code that read from one file and wrote to another but was not contained within a test_
prefixed function. Pytest now runs in about 0.03 seconds. Why is that? I thought tests were independent of program function.