Example #1
0
def test_del():
    pth = Perth()
    pth.set_seed('test', 100)
    pth.test += 10

    del pth.test
    assert pth.test == 100
Example #2
0
def test_get_f():
    pth = Perth()

    @pth.set_seed_f
    def test():
        return 100

    assert pth.get_seed('test') == 100
Example #3
0
def test_counting():
    results = {'main': False, 'sub': False}
    pth = Perth()

    pth.set_seed('test', 0)

    def f():
        pth.test += 1
        results['sub'] = pth.test == 1

    thread = threading.Thread(target=f)

    thread.start()
    pth.test += 1
    thread.join()

    results['main'] = pth.test == 1
    assert all(results.values())
Example #4
0
def test_get():
    pth = Perth()
    pth.set_seed('test', 1)
    assert pth.get_seed('test') == 1
Example #5
0
def test_remove():
    pth = Perth()
    pth.set_seed('test', 10)

    pth.remove_seed('test')
    pytest.raises(KeyError, pth.get_seed, 'test')