Skip to content

Collect all necessary system paths for import other modules #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

tamarinvs19
Copy link
Collaborator

@tamarinvs19 tamarinvs19 commented Dec 22, 2022

Description

Now sys.path contains path to testing file and paths to all imported modules. Due to this we can generate test if function uses import from another file.

Fixes #1562

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Manual Scenario

  1. Create module (directory) mod1
  2. Create two files mod1/a.py, mod1/b.py
  3. Put this code:
# file a
def sum(a, b):
    return a + b

#-------------------------------------------------
# file b
import a  # not <from mod1 import a>


def double_sum(n):
    return a.sum(n, n)
  1. Try to generate tests for double_sum function

Possible result
sHIjbVSfCE

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • No new warnings
  • All tests pass locally with my changes

@tamarinvs19 tamarinvs19 added ctg-bug Issue is a bug lang-python Issue is related to python support labels Dec 22, 2022
@tamarinvs19 tamarinvs19 enabled auto-merge (squash) December 22, 2022 07:05
@tamarinvs19 tamarinvs19 merged commit 2959469 into main Dec 22, 2022
@tamarinvs19 tamarinvs19 deleted the tamarinvs19/fix_python_imports branch December 22, 2022 07:15
denis-fokin pushed a commit that referenced this pull request Dec 23, 2022
@alisevych alisevych added ctg-bug-fix PR is fixing a bug and removed ctg-bug Issue is a bug labels Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-bug-fix PR is fixing a bug lang-python Issue is related to python support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot generate tests when user code calls function from another module
3 participants