Skip to content

Commit 09afa3a

Browse files
committed
added test yml
1 parent e6deee9 commit 09afa3a

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

.github/workflows/short_test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: My first Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
test:
10+
runs-on: [ubuntu-latest, windows-latest]
11+
defaults:
12+
run:
13+
working-directory: ./
14+
strategy:
15+
matrix:
16+
python-version: [3.8, 3.12]
17+
18+
env:
19+
NFAK: "1"
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up Environment
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version}}
27+
28+
- name: Install Dependencies
29+
run:
30+
python -m pip install --upgrade pip
31+
pip install -r unittest
32+
33+
- name: Test Function
34+
run: python ./faculty_test.py

faculty.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import os
2+
13
def my_faculty(n):
4+
if isinstance(n, str):
5+
n = int(os.environ.get(n))
26
mul = 1
37
if n==0:
48
return 1

faculty_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
from faculty import my_faculty
33

44
class MyTest(unittest.TestCase):
5-
def test(self):
5+
def test5(self):
66
self.assertEqual(my_faculty(5), 120)
7+
def test0(self):
8+
self.assertEqual(my_faculty(0), 1)
9+
def testEnviron(self):
10+
self.assertEqual(my_faculty("NFAK"), 1)
711

12+
if __name__ == "__main__":
13+
unittest.main()

0 commit comments

Comments
 (0)