Skip to content

tblanarik/actions-ci-unittest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python Unittests with GitHub Actions

This is a simple GitHub repository that shows how you can use GitHub Actions to run unittests on Python code.

The configuration for the Actions workflow is found here at .github/workflows/py-unittest.yml, and it simply runs the command:

- name: Run all Python unittests
run: python -m unittest *.py

One of the tests to be run has a failure due to some bad math 😏:

def test_bad_math(self):
# This test will fail because 2+2 = 4
self.assertEqual(2+2, 5)

Tests failing

Test My Python

To see the failing test results, visit the results of this job.

You'll notice that the test failed and the reason given is:

AssertionError: 4 != 5

CleanShot 2022-11-02 at 12 09 50

Fix the failing test

Test My Python

You can easily fix the failing test with this Pull Request- "Fix Failing Unittest"

CleanShot 2022-11-02 at 12 57 28

And sure enough, the tests pass and the GitHub Actions workflow shows green 🟢:

CleanShot 2022-11-02 at 12 14 40

As well as when looking at the Pull Request itself:

CleanShot 2022-11-02 at 12 14 52

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages