Skip to content
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

fix: SameFileError #1153 #1220

Merged
merged 4 commits into from Nov 27, 2021
Merged

fix: SameFileError #1153 #1220

merged 4 commits into from Nov 27, 2021

Conversation

stydodt
Copy link
Contributor

@stydodt stydodt commented Oct 15, 2021

Description

Pull request to fix bug #1153.

When relative paths were provided to rules with the --generate-unit-tests flag the target path and the tests were successfully created. However, when full paths were used, the automatic unittest generation failed. This was caused by behavior of the Path.parent() property. As path and f.parent are matching this leads to f and target matching and the SameFileError raised by shutils.

Behaviour of Path.parent:

>>> from pathlib import Path
>>> f = Path("/dummy/test/path")
>>> f.parent
PosixPath('/dummy/test')
>>> path = Path("/dummy/test/path/")
>>> rulename = "test"
>>> content_type = "expected"
>>> target = path / rulename / content_type / f.parent
>>> target
PosixPath('/dummy/test')

Removing f.parent creates a successful, matching folder structure with both relative and full paths and allows unittests to be generated.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

…vided, matching file and target locations.
@stydodt stydodt requested a review from johanneskoester as a code owner Oct 15, 2021
@stydodt stydodt changed the title Fixes https://github.com/snakemake/snakemake/issues/1153 fix: SameFileError #1153 Oct 15, 2021
@sonarcloud
Copy link

sonarcloud bot commented Oct 21, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@johanneskoester
Copy link
Contributor

johanneskoester commented Oct 21, 2021

The tests seem to fail now, can you have a look?

@stydodt
Copy link
Contributor Author

stydodt commented Nov 4, 2021

Sorry for the delay - I did not get a notification from Github about activity. Thanks for running the pipeline. I must have set my local environment incorrectly as I didn't spot this when I ran the tests - I will investigate.

EDIT: I can now recreate this error locally.

@sonarcloud
Copy link

sonarcloud bot commented Nov 26, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@johanneskoester johanneskoester merged commit ede313d into snakemake:main Nov 27, 2021
6 checks passed
@stydodt stydodt deleted the generate_unittests_bug_1153 branch Dec 3, 2021
@stydodt
Copy link
Contributor Author

stydodt commented Dec 3, 2021

Thanks for finishing and merging this @johanneskoester ! Getting the tests working was proving challenging given the time constraints and being new to the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants