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
UnitTestBot generates tests with invalid sys.path on Windows when "Test sources root" coincides with file under test.
To Reproduce
Steps to reproduce the behavior:
Run a python project in Pycharm
Use plugin to generate tests and set a path to directory with tested file in the field "Test sources root"
Open the generated test
Expected behavior
Valid tests with correct sys paths
Actual behavior
Valid tests with incorrect sys path (sys.path.append(os.path.dirname(__file__) + r'\')). The problem is that python raw-string cannot end in backslash.
Visual proofs (screenshots, logs, images)
Tested function
UTBot window
sys.path
Environment
Windows + specified above "Test sources root"
Solutions
Replace backslash at the end by "\."
Remove backslash at the end
Skip sys.path if it coincides with tested function directory
The text was updated successfully, but these errors were encountered:
tamarinvs19
changed the title
Invalid python sys path to current directory on Windows
Invalid python sys path to test file directory on Windows
Nov 3, 2023
tamarinvs19
changed the title
Invalid python sys path to test file directory on Windows
Invalid python sys path to directory with tested file on Windows
Nov 3, 2023
Description
UnitTestBot generates tests with invalid sys.path on Windows when "Test sources root" coincides with file under test.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Valid tests with correct sys paths
Actual behavior
Valid tests with incorrect sys path (
sys.path.append(os.path.dirname(__file__) + r'\')
). The problem is that python raw-string cannot end in backslash.Visual proofs (screenshots, logs, images)

Tested function
UTBot window

sys.path

Environment
Windows + specified above "Test sources root"
Solutions
The text was updated successfully, but these errors were encountered: