Loading Makefile +8 −0 Original line number Diff line number Diff line Loading @@ -4,3 +4,11 @@ install: uninstall: pip uninstall csst_proto -y test: coverage run -m pytest . --import-mode=importlib --cov-report=html --cov-report=term-missing coverage report -m rm -rf .coverage .pytest_cache csst_proto/__init__.py +2 −0 Original line number Diff line number Diff line Loading @@ -3,8 +3,10 @@ from .flip_image import flip_image, read_default_image from .flip_image_in_parallel import flip_multiple_images_jl, flip_multiple_images_mp from .config import read_config # 版本号,可以通过csst_proto.__version__获取 __version__ = "0.0.1" # 定义__all__变量,其中所有的对象会被检查类型标注和docstring __all__ = [ "demo_function", "DemoClass", Loading csst_proto/flip_image.py +1 −1 Original line number Diff line number Diff line Loading @@ -75,6 +75,6 @@ def read_default_image(): -------- >>> test_image = read_default_image() """ fp_img = os.path.join(HERE, "/data/test_image.txt") fp_img = os.path.join(HERE, "data/test_image.txt") print("reading file {} ...".format(fp_img)) return np.loadtxt(fp_img, dtype=int) tests/test_config.py 0 → 100644 +37 −0 Original line number Diff line number Diff line """ Identifier: csst_proto/test_config.py Name: test_config.py Description: Test reading toml format config. Author: Bo Zhang Created: 2023-10-26 Modified-History: 2023-10-26, Bo Zhang, created 2023-10-26, Bo Zhang, add module header """ import unittest from csst_proto import read_config class TestDemoFunction(unittest.TestCase): def test_read_config(self): """ Aim --- Test demo function. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ # demo function test config = read_config() self.assertTrue( set(config.keys()) == {"A", "B"} and config["A"] == 1 and config["B"] == 2, "Single-argument case failed.", ) tests/test_demo_function.py +6 −6 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ Modified-History: """ import unittest from csst_proto.api import a_demo_function from csst_proto import demo_function class TestDemoFunction(unittest.TestCase): Loading @@ -31,7 +31,7 @@ class TestDemoFunction(unittest.TestCase): """ # demo function test self.assertTrue( a_demo_function(None) == 1, demo_function(None) == 1, "Single-argument case failed.", ) Loading @@ -52,7 +52,7 @@ class TestDemoFunction(unittest.TestCase): """ # demo function test self.assertEqual( a_demo_function(None, None), demo_function(None, None), 2, "Double-argument case failed.", ) Loading @@ -61,7 +61,7 @@ class TestDemoFunction(unittest.TestCase): """ Aim --- Test demo function. Test demo function in bad case. Criteria -------- Loading @@ -74,8 +74,8 @@ class TestDemoFunction(unittest.TestCase): if input is `None, None, None`. """ # demo function test self.assertNotEquals( a_demo_function(None, None, None), self.assertNotEqual( demo_function(None, None, None), 2, "Triple-argument case failed.", ) Loading
Makefile +8 −0 Original line number Diff line number Diff line Loading @@ -4,3 +4,11 @@ install: uninstall: pip uninstall csst_proto -y test: coverage run -m pytest . --import-mode=importlib --cov-report=html --cov-report=term-missing coverage report -m rm -rf .coverage .pytest_cache
csst_proto/__init__.py +2 −0 Original line number Diff line number Diff line Loading @@ -3,8 +3,10 @@ from .flip_image import flip_image, read_default_image from .flip_image_in_parallel import flip_multiple_images_jl, flip_multiple_images_mp from .config import read_config # 版本号,可以通过csst_proto.__version__获取 __version__ = "0.0.1" # 定义__all__变量,其中所有的对象会被检查类型标注和docstring __all__ = [ "demo_function", "DemoClass", Loading
csst_proto/flip_image.py +1 −1 Original line number Diff line number Diff line Loading @@ -75,6 +75,6 @@ def read_default_image(): -------- >>> test_image = read_default_image() """ fp_img = os.path.join(HERE, "/data/test_image.txt") fp_img = os.path.join(HERE, "data/test_image.txt") print("reading file {} ...".format(fp_img)) return np.loadtxt(fp_img, dtype=int)
tests/test_config.py 0 → 100644 +37 −0 Original line number Diff line number Diff line """ Identifier: csst_proto/test_config.py Name: test_config.py Description: Test reading toml format config. Author: Bo Zhang Created: 2023-10-26 Modified-History: 2023-10-26, Bo Zhang, created 2023-10-26, Bo Zhang, add module header """ import unittest from csst_proto import read_config class TestDemoFunction(unittest.TestCase): def test_read_config(self): """ Aim --- Test demo function. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ # demo function test config = read_config() self.assertTrue( set(config.keys()) == {"A", "B"} and config["A"] == 1 and config["B"] == 2, "Single-argument case failed.", )
tests/test_demo_function.py +6 −6 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ Modified-History: """ import unittest from csst_proto.api import a_demo_function from csst_proto import demo_function class TestDemoFunction(unittest.TestCase): Loading @@ -31,7 +31,7 @@ class TestDemoFunction(unittest.TestCase): """ # demo function test self.assertTrue( a_demo_function(None) == 1, demo_function(None) == 1, "Single-argument case failed.", ) Loading @@ -52,7 +52,7 @@ class TestDemoFunction(unittest.TestCase): """ # demo function test self.assertEqual( a_demo_function(None, None), demo_function(None, None), 2, "Double-argument case failed.", ) Loading @@ -61,7 +61,7 @@ class TestDemoFunction(unittest.TestCase): """ Aim --- Test demo function. Test demo function in bad case. Criteria -------- Loading @@ -74,8 +74,8 @@ class TestDemoFunction(unittest.TestCase): if input is `None, None, None`. """ # demo function test self.assertNotEquals( a_demo_function(None, None, None), self.assertNotEqual( demo_function(None, None, None), 2, "Triple-argument case failed.", )