mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-07 03:57:45 +00:00
fix mypy error (#91)
* fix mypy error * fix mypy error * fix ruff error * change command * delete python 3.8&3.9 from CI * change command * Some modifications according to the comments * Add literal type * Update .github/workflows/ci.yml * Some modifications according to the comments * fix ruff error * fix meta dict * Fix type * Some modifications according to the comments * merge latest code * Some modifications according to the comments * Some modifications according to the comments * fix ci error * fix ruff error * Update Makefile * Update Makefile --------- Co-authored-by: Ubuntu <debug@debug.qjtqi00gqezu1eqs55bqdrf51f.px.internal.cloudapp.net> Co-authored-by: Young <afe.young@gmail.com> Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user