12rambau / pytest-copie

The pytest plugin for your copier templates 📒
https://pytest-copie.readthedocs.io/en/latest/
MIT License
15 stars 5 forks source link

Ensure demo example works without error #49

Closed GenevieveBuckley closed 10 months ago

GenevieveBuckley commented 11 months ago

Closes https://github.com/12rambau/pytest-copie/issues/48

GenevieveBuckley commented 11 months ago

I'm not entirely sure how to handle all the assert result.project_dir.name == statements scattered through usage.rst.

Since this isn't what actually happens when you run pytest-copie, we should change them. result.project_dir is generally the temp pytest folder, named something like copie0001, copie0002, etc. which doesn't give us a meaningful name attribute.

I count 4 places where this is written in the docs:

  1. https://github.com/12rambau/pytest-copie/blame/c9f5e3f435c8d56fefb969814102345d051540e2/README.rst#L77
  2. https://github.com/12rambau/pytest-copie/blame/c9f5e3f435c8d56fefb969814102345d051540e2/docs/usage.rst#L49
  3. https://github.com/12rambau/pytest-copie/blame/c9f5e3f435c8d56fefb969814102345d051540e2/docs/usage.rst#L79
  4. https://github.com/12rambau/pytest-copie/blame/c9f5e3f435c8d56fefb969814102345d051540e2/docs/usage.rst#L111

For (2) and (3) I can do this, because we have prior knowledge about what the contents of the README.rst.jinja file is supposed to be:

assert result.project_dir.is_dir()
with open(result.project_dir/"README.rst") as f:
    assert f.readline() == "foobar\n"  # or "helloworld\n"

For (1), we don't have any prior knowledge of the template contents, so we can't do this. It might be best to just remove that line. That might not be a great solution, but it is better than keeping the inaccurate info.

For (4), I'm not sure. I haven't used custom templates yet. I'll have to try it out and see what happens.

codecov[bot] commented 11 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c9f5e3f) 98.59% compared to head (532f736) 96.00%. Report is 4 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #49 +/- ## ========================================== - Coverage 98.59% 96.00% -2.60% ========================================== Files 2 2 Lines 71 75 +4 ========================================== + Hits 70 72 +2 - Misses 1 3 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

GenevieveBuckley commented 10 months ago

Nice catch - I totally assumed I was appending to that file instead of overwriting it, thank you! I think it should be fixed now.