Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Invalid python sys path to directory with tested file on Windows #2673

Closed
Assignees
Labels
ctg-bugIssue is a bug lang-pythonIssue is related to python support
@tamarinvs19

Description

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:

  1. Run a python project in Pycharm
  2. Use plugin to generate tests and set a path to directory with tested file in the field "Test sources root"
  3. 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
tested function

UTBot window
utbot ui

sys.path
sys paths

Environment

Windows + specified above "Test sources root"

Solutions

  1. Replace backslash at the end by "\."
  2. Remove backslash at the end
  3. Skip sys.path if it coincides with tested function directory

Metadata

Metadata

Labels

ctg-bugIssue is a bug lang-pythonIssue is related to python support

Type

No type

Projects

Status

Done

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /