htw-imi-info3 / python-learning

0 stars 2 forks source link

Learn Python with Unit Tests

This is a little example for learning Python using unit tests.

Usage

As you study the language, add little examples as tests.

This enables you to look up the syntax quickly later.

By keeping the tests running, you can be certain that the examples are correct.

Tests are especially useful if you tryout behaviour of the language that is not immediately clear to you. Try out the behaviour and assert the results with unit tests assertions. This way, you can even look up the output/results without having to run the code again and frequently needing to check the output.

Running the Tests

Single Files

    python3 <file-name>

Unit tests are called because of this boilerplate in the files, if you add a file be sure to include it:

if __name__ == '__main__':
    unittest.main()

Run all Files

run all tests with:

    python3 -m unittest about/test_*.py

To ensure that all examples are correct.

Unit Tests in Python

https://docs.python.org/3/library/unittest.html

Sources for Python

Things to explore

Control Structures

Data Structures

Object Oriented Programming

What is the Type model?

How to interact with the language / Structure of a Program