Skip to content

Add tests with pytest #133

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

Merged
merged 60 commits into from
Jun 23, 2020
Merged

Add tests with pytest #133

merged 60 commits into from
Jun 23, 2020

Conversation

huguesdevimeux
Copy link
Member

@huguesdevimeux huguesdevimeux commented Jun 3, 2020

So I created a bunch of tests for pytest. To run them, pytest command is enoug
I tried to test pretty much all of the features that manim currently has. Don't hesitate to tell if some miss.

Functioning :

See #34 and #97.
For performances purpose it just compares the last frame with a previously-rendered one (and not a frame every n seconds, as it was mentioned in #34. On my computer, it takes around 30 seconds.

Adding a new test

I created the function utils.set_test that is intended to be used when we add a new feature.
I think that we should create a section in the wiki to explain how to create a new test and mention it in #127.

For the moment I marked this PR as a draft since it uses some stuff (see conftest.py) that will be completely rewritten when #98 is merged.

closes #28 closes #34 closes #97

@huguesdevimeux huguesdevimeux added the testing Anything related to testing the library label Jun 4, 2020
@huguesdevimeux huguesdevimeux marked this pull request as ready for review June 4, 2020 16:43
@leotrs leotrs mentioned this pull request Jun 7, 2020
13 tasks
@leotrs leotrs added this to the PyPI Release 1.0.0 milestone Jun 7, 2020
- cmd.exe //c "RefreshEnv.cmd"
- python -m pip install --upgrade pip
- python -m pip install --user -r ./.travis/travis-requirements.txt
- python ./scripts/pycairoinstall.py
- cmd.exe //c "RefreshEnv.cmd"
- python -m pip install --user .
script:
- python -m pytest
- python -m pytest --skip_end_to_end -rs
Copy link

@hadichaudhri hadichaudhri Jun 20, 2020

Choose a reason for hiding this comment

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

Same thing (as far as DRY goes) for Windows here. We probably want to use a .bat script to set up the environment.

Choose a reason for hiding this comment

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

This comment was supposed to be 3 lines up in before-install, but you get the gist.

@huguesdevimeux
Copy link
Member Author

huguesdevimeux commented Jun 21, 2020

As a lot of things depend on when this PR is merged, I propose to merge it now.

All of the suggestions that had been said here were all very good and I'm working on them, but they don't concern the core of the tests. I will do another PR.

Copy link
Member

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

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

what are the tests_cache and tests_data directories for? Shouldn't Travis or whatever automatically generate those folders? Then they shouldn't be in the repo and should be in .gitignore
Also, should we follow guidelines and also add typings to the testing_utils.py file?

@huguesdevimeux
Copy link
Member Author

what are the tests_cache and tests_data directories for? Shouldn't Travis or whatever automatically generate those folders? Then they shouldn't be in the repo and should be in .gitignore
Also, should we follow guidelines and also add typings to the testing_utils.py file?

These files are the whole point of the tests. tests_data contains the previously rendered frames that serve for the comparison (if the frames match, then all good and if not, a thing had been changed). Thus, in essence, it can't be generated by Travis itself.
tests_cache is the cache used sometimes in the tests. In that case, for the moment, only TexTest uses it, because the purpose of this test is not to test the caching functionality of manim. That is tested somewhere else, in an end-to-end test.

About typing stuff, maybe you're right but that's not the correct PR to do that, I think.

@PgBiel
Copy link
Member

PgBiel commented Jun 21, 2020

These files are the whole point of the tests. tests_data contains the previously rendered frames that serve for the comparison (if the frames match, then all good and if not, a thing had been changed). Thus, in essence, it can't be generated by Travis itself.

I see. In this case, the files should be stored elsewhere in my opinion, such as in a separate branch or site or whatever, then we should have Travis fetch those.

tests_cache is the cache used sometimes in the tests. In that case, for the moment, only TexTest uses it, because the purpose of this test is not to test the caching functionality of manim. That is tested somewhere else, in an end-to-end test.

Same comment as above ^

About typing stuff, maybe you're right but that's not the correct PR to do that, I think.

You're probably right, but what about documentation following the guidelines?

@huguesdevimeux
Copy link
Member Author

I see. In this case, the files should be stored elsewhere in my opinion, such as in a separate branch or site or whatever, then we should have Travis fetch those.

To be honest, I don't think this is a good idea. For two main reasons :

  • This seems to be complicated to set up and .. maybe it is not worth it. But I'm not an expert, so maybe I'm wrong here.
  • We have to think of when someone adds new functionality or modify one, one must be able to add/modify a frame contained in test_data. With this system, this would make the thing not simple.

But why do you want this? Is there like a convention or something? Or is it just cleaner ?

For documentation following the guidelines, you are totally right. I will commit asap.

huguesdevimeux and others added 3 commits June 21, 2020 22:05
Co-authored-by: Pg Biel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: Pg Biel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: Pg Biel <9021226+PgBiel@users.noreply.github.com>
@PgBiel
Copy link
Member

PgBiel commented Jun 21, 2020

But why do you want this? Is there like a convention or something? Or is it just cleaner ?

I simply thought it would be cleaner in a way, given that we will all be cloning this repo (+ users downloading, soon) so I thought it would be a good idea to not have a lot of otherwise irrelevant "bloat" yk. There probably are alternatives here, but we gotta think this through

@huguesdevimeux
Copy link
Member Author

Then if you find a way that would be nice, I would suggest doing a new PR

@leotrs
Copy link
Contributor

leotrs commented Jun 21, 2020

The test cache files are an integral part of the testing system we have setup. I think they should be in this repo, in the tests directory.

@huguesdevimeux you do raise a good point. Most of our comments were not about the core testing system that this is setting up. Can I ask you to please extract the standing discussion points and making separate issues for those that warrant it?

If you think this is ready to be merged, then say so and I'll merge it.

@huguesdevimeux huguesdevimeux mentioned this pull request Jun 23, 2020
@leotrs leotrs merged commit 4b6492b into ManimCommunity:master Jun 23, 2020
@leotrs leotrs changed the title Add tests with pytest (WIP) Add tests with pytest Jun 23, 2020
leotrs added a commit that referenced this pull request Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Anything related to testing the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing process How to test videos?
6 participants