* - fix pytest setup that can be startet from the rootdir - support python venv environment - add pytest.ini - move common settings from .vscode/settings.json into pytest.ini - add missing requirements - fix import paths for pytests * - support python venv environment * initial version * - add missing requirements python-dotenv * fix import paths for pytests * fix pytest warnings * initial version * report 5 slowest test durations * add more vscode settings for python
20 lines
476 B
Python
20 lines
476 B
Python
# test_with_pytest.py
|
|
import pytest
|
|
from singleton import Singleton
|
|
|
|
class Example(metaclass=Singleton):
|
|
def __init__(self):
|
|
pass # is a dummy test class
|
|
|
|
def test_singleton_metaclass():
|
|
Singleton._instances.clear()
|
|
a = Example()
|
|
assert 1 == len(Singleton._instances)
|
|
b = Example()
|
|
assert 1 == len(Singleton._instances)
|
|
assert a is b
|
|
del a
|
|
assert 1 == len(Singleton._instances)
|
|
del b
|
|
assert 0 == len(Singleton._instances)
|