-
Notifications
You must be signed in to change notification settings - Fork 671
test(ci): create a dummy ~/.python-gitlab.cfg file #2174
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
Conversation
Once PR #2173 is merged, then this will pass the CI. |
9855d56
to
183d6ff
Compare
Create a working ~/.python-gitlab.cfg file when running the unit tests in the CI. This is to ensure our unit tests still work if a config file exists.
183d6ff
to
0f4fa8f
Compare
Codecov Report
@@ Coverage Diff @@
## main #2174 +/- ##
==========================================
+ Coverage 91.56% 95.56% +4.00%
==========================================
Files 81 81
Lines 5344 5344
==========================================
+ Hits 4893 5107 +214
+ Misses 451 237 -214
Flags with carried forward coverage won't be shown. Click here to find out more.
|
We have since added #2187 where we ignore default files including /etc/python-gitlab.cfg now at root-level. |
True. But what if in the future we break it accidentally... I don't have that strong of feelings about this but just thought a little extra safety. |
It's fine with me if you want to go ahead and just close it 👍 |
I'm still thinking about what to do with it :D for me not having extra bash scripts would be nicer*, as it usually doesn't make sense to lint them and other contributors would then get comfortable and start adding more and more potentially, but I also get your point. Maybe also a *I'm biased because I removed a bunch of them https://github.com/python-gitlab/python-gitlab/tree/v2.2.0/tools :D |
I think this could also be implemented as a top-level fixture, to keep things in one language and less code.
import os
from pathlib import Path
@pytest.fixture(autouse=True, scope="session")
def dummy_config() -> None:
"""
Creates a dummy config file that should never affect our tests.
See https://github.com/python-gitlab/python-gitlab/issues/2172.
"""
config = Path.home() / ".python-gitlab.cfg"
if config.exists() or "CI" not in os.environ:
return
config.write_text("""[global]
default = gitlab
[gitlab]
url = https://gitlab.example.com
private_token = not-a-valid-token
""")
yield
config.unlink(missing_ok=True) For good measure, could also be included in the gitlab fixture then to ensure it's loaded first. https://stackoverflow.com/a/38611500/15836334 |
Create a working ~/.python-gitlab.cfg file when running the unit
tests in the CI. This is to ensure our unit tests still work if a config file
exists.