Skip to content

Commit dc269e9

Browse files
committed
[+] add unit test
1 parent 8dd1d8c commit dc269e9

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3838
- name: Test with pytest
3939
run: |
40-
pytest
40+
pytest tests/test_create_totalseg_subset.py
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# FILE: tests/test_create_totalseg_subset.py
2+
import unittest
3+
import pandas as pd
4+
import os
5+
from scripts.create_totalseg_subset import plot_and_save_distribution
6+
7+
class TestCreateTotalSegSubset(unittest.TestCase):
8+
def setUp(self):
9+
# Create a sample dataframe
10+
self.data = pd.DataFrame({
11+
'age': [25, 35, 45, 55, 65, 75],
12+
'gender': ['M', 'F', 'M', 'F', 'M', 'F']
13+
})
14+
self.filename = 'test_distribution.png'
15+
16+
def test_plot_and_save_distribution(self):
17+
# Call the function to plot and save the distribution
18+
plot_and_save_distribution(self.data, "Test Title", self.filename)
19+
20+
# Check if the file is created
21+
self.assertTrue(os.path.exists(self.filename))
22+
23+
def tearDown(self):
24+
# Remove the file after test
25+
if os.path.exists(self.filename):
26+
os.remove(self.filename)
27+
28+
if __name__ == '__main__':
29+
unittest.main()

0 commit comments

Comments
 (0)