Sonar qube 3 (#166)
* add unittests for mqtt.py * add mock * move test requirements into a file * fix unit tests * fix formating * initial version * fix SonarQube warning
This commit is contained in:
18
app/tests/test_singleton.py
Normal file
18
app/tests/test_singleton.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# 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():
|
||||
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)
|
||||
Reference in New Issue
Block a user