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

add support for \ character in pytest temporary path - Closes #982 #985

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

bhelgs
Copy link
Contributor

@bhelgs bhelgs commented Jul 17, 2024

Description

add support for \ character in pytest temporary path - Closes #982

Testing:

You can see I have broken the PR into two commits.
In the first commit the new test fails on a "good" machine (XFAIL):
image
The second commit adds the fix. The tests PASSED on both "good" and "bad" machines:
image

Chore

Chore that needs to be done:

  • Add newsfragment pipenv run towncrier create [issue_number].[type].rst

P.S.

I noticed flake8 is failing in the pre-commit hook.
I'll assume I should be using ruff now and the hook is just out of date..

@bhelgs bhelgs force-pushed the bad_tmp_path branch 2 times, most recently from 809dc4c to 4734c6b Compare July 17, 2024 20:38
@fizyk
Copy link
Member

fizyk commented Jul 18, 2024

🤔 pre-comit-config hasn't been updated in years, don't mind it for the time being. It should be addressed separately

newsfragments/982.misc.rst Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.83%. Comparing base (22944af) to head (a24d7dc).
Report is 233 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #985      +/-   ##
==========================================
+ Coverage   95.26%   95.83%   +0.57%     
==========================================
  Files          13       13              
  Lines         401      432      +31     
==========================================
+ Hits          382      414      +32     
+ Misses         19       18       -1     
Flag Coverage Δ
unittests 95.83% <100.00%> (+0.57%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bhelgs bhelgs force-pushed the bad_tmp_path branch 2 times, most recently from e6768eb to 9681a5a Compare July 18, 2024 12:59
return tmp_path_factory.mktemp(rf"bad\path/{subdir}")

with mock.patch("pytest_postgresql.factories.process._tmp_dir", side_effect=bad_path):
assert postgresql_proc.running() is True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm... looking at the test here. Executor at this stage is already started, it is running when you run first test with postgresql_proc.
It would be better I think to add test in test_executors, and instantiate the PostgreSQL executor there directly.
making the function _tmp_dir obsolete.

Copy link
Contributor Author

@bhelgs bhelgs Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. Thanks a lot! Done.

The new test has quite a bit of duplicate with the test_executor_init_with_password test, including the skipif.
It may be reasonable to refactor some more. I'm just not sure what to do yet.

Copy link
Contributor Author

@bhelgs bhelgs Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want I can open a new pull request to refactor.
This change damages test encapsulation, but at least I think it might resolve the skipif issue and maybe reduce test maintainance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just going to say that I did deduplicated these tests when fixing #343, but I was unable to duplicate the issue in tests, and just reverted any changes I made to tests 🤔

Refactor looks good to me, note that port_for already contains PortType definition you can import and use.

Copy link
Contributor Author

@bhelgs bhelgs Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was on vacation and then got a bit distracted.

I'll treat the refactor as a separate PR.
Also, I was able to reproduce and add a test for what you fixed in PR #965. So I'll rebase this PR on top of the refactor.

What I did was add (nl_NO.UTF-8) and confirm it fails without the fix you made in PR #965:
image
`
(Not all languages encounter the issue that you fixed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I do get distracted as as well.
Got three distractions distracting me around the house ;)

Not all languages encounter the issue that you fixed

I wasn't expecting that 🤦🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@bhelgs bhelgs marked this pull request as draft August 24, 2024 22:10
@bhelgs bhelgs force-pushed the bad_tmp_path branch 2 times, most recently from c0d04f8 to 802a667 Compare September 3, 2024 23:53
@bhelgs
Copy link
Contributor Author

bhelgs commented Sep 4, 2024

I have rebased this change on top of our other recent updates.

The test confirms the path can contain backslashes, "\", as well as spaces, " ".

@bhelgs bhelgs marked this pull request as ready for review September 4, 2024 00:04
@fizyk fizyk merged commit fa9432a into ClearcodeHQ:main Sep 4, 2024
48 checks passed
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.

support \ in linux temporary path
3 participants