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

Create tests #45

Open
9 tasks
niccokunzmann opened this issue Jan 22, 2017 · 4 comments
Open
9 tasks

Create tests #45

niccokunzmann opened this issue Jan 22, 2017 · 4 comments

Comments

@niccokunzmann
Copy link
Owner

niccokunzmann commented Jan 22, 2017

Somehow, we need to rewrite everything to be nicely testable. To create tests

  • choose a test framework (unittest/nosetest/pytest)
  • create a folder with some tests
  • make travis execute the tests and fail if they fail
  • for a new version: ship the folder of the module with example and the tests together in the source code - we want to be able to run the tests in production systems.
  • to test and to mock:
    • millisenconds time.sleep
    • changing the execution of the thread
    • the logging
    • multithreading: mock it: split the loop into a loop and an update function.
    • ...

The testing can be an excellent basis to transform and refactor the module.
These are many steps. If you help with one of them or you would like to add some, feel welcome to comment.

@MarkoMackic
Copy link
Collaborator

Any opinion how to do tests ?

@artemrizhov
Copy link
Collaborator

artemrizhov commented Jan 22, 2017

I think the test should test the lib itself, not it's internal interfaces. I.e. it should monitor the monitor, create hanging threads and check the logged messages.

@artemrizhov
Copy link
Collaborator

choose a test framework (unittest/nosetest/pytest)

Any framework will work for this simple task, I think. However it would be nice if the framework supports mocking. For example we can mock the write_log() function to check if it writes correct messages.

@niccokunzmann
Copy link
Owner Author

Here is an example of how I created automatic tests: https://github.com/fossasia/knittingpattern
There are a lot of other possibilities for Python modules. e.g. for libraries like Pillow, bottle, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants