File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI Workflow
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ test :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v2
18+
19+ - name : Set up Python
20+ uses : actions/setup-python@v2
21+ with :
22+ python-version : ' 3.9'
23+
24+ - name : Install dependencies
25+ run : |
26+ python -m pip install --upgrade pip
27+ pip install pytest streamlit
28+
29+ - name : Run tests
30+ run : |
31+ pytest _test.py
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ # Function to test square
4+ def square (n ):
5+ return n ** 2
6+
7+ # Function to test cube
8+ def cube (n ):
9+ return n ** 3
10+
11+ # Function to test fifth power
12+ def fifth_power (n ):
13+ return n ** 5
14+
15+ # Testing the square function
16+ def test_square ():
17+ assert square (2 ) == 4 , "Test Failed: Square of 2 should be 4"
18+ assert square (3 ) == 9 , "Test Failed: Square of 3 should be 9"
19+
20+ # Testing the cube function
21+ def test_cube ():
22+ assert cube (2 ) == 8 , "Test Failed: Cube of 2 should be 8"
23+ assert cube (3 ) == 27 , "Test Failed: Cube of 3 should be 27"
24+
25+ # Testing the fifth power function
26+ def test_fifth_power ():
27+ assert fifth_power (2 ) == 32 , "Test Failed: Fifth power of 2 should be 32"
28+ assert fifth_power (3 ) == 243 , "Test Failed: Fifth power of 3 should be 243"
29+
30+ # Test for invalid input
31+ def test_invalid_input ():
32+ with pytest .raises (TypeError ):
33+ square ("string" )
You can’t perform that action at this time.
0 commit comments