Skip to content

Commit

Permalink
test(refactor): no need for options_baked to return another fixure
Browse files Browse the repository at this point in the history
It's returning configuration, so the places that need the configuration
can get it directly instead of having options_baked return it.
  • Loading branch information
Ned Batchelder committed Aug 7, 2023
1 parent 104a905 commit c49cc73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tests/common_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
from .venv import all_files


def test_github_org_is_right(options_baked):
def test_github_org_is_right(options_baked, configuration): # pylint: disable=unused-argument

This comment has been minimized.

Copy link
@timmc-edx

timmc-edx Aug 7, 2023

Contributor

Hmm. Why did pylint complain about this, but not about the unused options_baked in test_models?

This comment has been minimized.

Copy link
@nedbat

nedbat Aug 7, 2023

Contributor

Because it's disabled for the entire test file:

# Fixture names aren't always used in test functions. Disable completely.
# pylint: disable=unused-argument

I guess that's a better way to approach it here too. This file is a file full of tests. I'll change it.

"""Make sure no one hard-coded openedx as the GitHub organization."""
org = options_baked["github_org"]
repo = options_baked["repo_name"]
org = configuration["github_org"]
repo = configuration["repo_name"]

right_github = f"github.com/{org}/{repo}"
if org != "openedx":
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ def options_baked(cookies_session, configuration, custom_template):
with bake_in_temp_dir(cookies_session, extra_context=configuration, template=custom_template):
sh.make('upgrade')
sh.pip('install', '-r', 'requirements/test.txt')
yield configuration
yield
6 changes: 3 additions & 3 deletions tests/test_cookiecutter_django_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def test_readme(options_baked, custom_template):
sh.twine("check", "dist/*")


def test_models(options_baked):
def test_models(options_baked, configuration):
"""The generated models.py file should pass a sanity check."""
if "models" not in options_baked:
if "models" not in configuration:
pytest.skip("No models to check")
model_txt = Path("cookie_lover/models.py").read_text()
for model_name in options_baked.get("models").split(","):
for model_name in configuration.get("models").split(","):
pattern = fr'^class {model_name}\(TimeStampedModel\):$'
assert re.search(pattern, model_txt, re.MULTILINE)

Expand Down

0 comments on commit c49cc73

Please sign in to comment.