From 9481e6fcaa6c7603002407b5ae5779a59a970d4e Mon Sep 17 00:00:00 2001 From: Huxley Deng Date: Mon, 22 May 2023 17:10:59 +0800 Subject: [PATCH] Build Project Structure. New: base classes and modules. New: unit tests. --- __init__.py | 0 core/__init__.py | 0 core/base/ResultBase.py | 2 ++ core/base/SimulationBase.py | 9 +++++++++ core/base/__init__.py | 2 ++ tests/__init__.py | 0 tests/test_base.py | 18 ++++++++++++++++++ 7 files changed, 31 insertions(+) create mode 100644 __init__.py create mode 100644 core/__init__.py create mode 100644 core/base/ResultBase.py create mode 100644 core/base/SimulationBase.py create mode 100644 core/base/__init__.py create mode 100644 tests/__init__.py create mode 100644 tests/test_base.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/__init__.py b/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/base/ResultBase.py b/core/base/ResultBase.py new file mode 100644 index 0000000..e1abbce --- /dev/null +++ b/core/base/ResultBase.py @@ -0,0 +1,2 @@ +class ResultBase(): + pass diff --git a/core/base/SimulationBase.py b/core/base/SimulationBase.py new file mode 100644 index 0000000..fa985b5 --- /dev/null +++ b/core/base/SimulationBase.py @@ -0,0 +1,9 @@ +import abc + + +class SimulationBase(): + @abc.abstractclassmethod + def run(self): + pass + + pass diff --git a/core/base/__init__.py b/core/base/__init__.py new file mode 100644 index 0000000..da7f6e8 --- /dev/null +++ b/core/base/__init__.py @@ -0,0 +1,2 @@ +from .ResultBase import ResultBase +from .SimulationBase import SimulationBase diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_base.py b/tests/test_base.py new file mode 100644 index 0000000..204fc17 --- /dev/null +++ b/tests/test_base.py @@ -0,0 +1,18 @@ +import unittest + +from haocrowd.core.base import SimulationBase + + +class TestBase(unittest.TestCase): + + def test_basic(self): + class MySim(SimulationBase): + def run(self) -> str: + return "HelloSim" + + mysim = MySim() + self.assertEqual(mysim.run(), "HelloSim") + + +if __name__ == "__main__": + unittest.main()