Files
NexQuant/test/utils/test_misc.py
T
Linlang faa2fb03ad CI checks that can be automatically repaired (#119)
* fix isort & black & toml-sort & sphinx error

* fix ci error

* fix ci error

* add comments

* Update Makefile

* change sphinx build command

* add auto-lint

* add black args

* format with black

* Auto Linting document

* fix ci error

---------

Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
Co-authored-by: Young <afe.young@gmail.com>
2024-07-26 12:12:16 +08:00

43 lines
978 B
Python

import unittest
from rdagent.core.utils import SingletonBaseClass
class A(SingletonBaseClass):
def __init__(self, **kwargs):
self.kwargs = kwargs
class MiscTest(unittest.TestCase):
def test_singleton(self):
a1 = A()
a2 = A()
a3 = A(x=3)
a4 = A(x=2)
a5 = A(b=3)
a6 = A(x=3)
# Check that a1 and a2 are the same instance
self.assertIs(a1, a2)
# Check that a3 and a6 are the same instance
self.assertIs(a3, a6)
# Check that a1 and a3 are different instances
self.assertIsNot(a1, a3)
# Check that a3 and a4 are different instances
self.assertIsNot(a3, a4)
# Check that a4 and a5 are different instances
self.assertIsNot(a4, a5)
# Check that a5 and a6 are different instances
self.assertIsNot(a5, a6)
print(id(a1), id(a2), id(a3), id(a4), id(a5), id(a6))
if __name__ == "__main__":
unittest.main()