Files
tsun-gen3-proxy/app/tests/test_singleton.py
Stefan Allius f9c1b83ccd Sonar qube 4 (#169)
* add unit test for inverter.py

* fix SonarQube warning
2024-08-24 22:21:55 +02:00

20 lines
475 B
Python

# test_with_pytest.py
import pytest
from app.src.singleton import Singleton
class Test(metaclass=Singleton):
def __init__(self):
pass # is a dummy test class
def test_singleton_metaclass():
Singleton._instances.clear()
a = Test()
assert 1 == len(Singleton._instances)
b = Test()
assert 1 == len(Singleton._instances)
assert a is b
del a
assert 1 == len(Singleton._instances)
del b
assert 0 == len(Singleton._instances)