Ejemplo n.º 1
0
def test_environ_attrs():
    with Environ('myapp') as cfg:
        cfg.env.FOOL = 'Next time I send a damn fool, I go myself.'

    with Environ('myapp') as cfg:
        assert cfg.env['FOOL'] == 'Next time I send a damn fool, I go myself.'
        del cfg.env['FOOL']
        assert cfg.env['FOOL'] is None
Ejemplo n.º 2
0
def test_environ_vars():
    with Environ('myapp') as cfg:
        cfg.env['SHUTUP'] = 'Oh shut up! And go change your armour!'

    assert os.environ['SHUTUP'] == 'Oh shut up! And go change your armour!'

    with Environ('myapp') as cfg:
        assert cfg.env['SHUTUP'] == 'Oh shut up! And go change your armour!'
        del cfg.env['SHUTUP']
        assert cfg.env['SHUTUP'] is None
Ejemplo n.º 3
0
def test_environ_update():
    with Environ('myapp') as cfg:
        cfg.env.update({'__test_key1__': 'I', '__test_key2__': 'II'})
        assert os.environ['__test_key1__'] == 'I'
        assert os.environ['__test_key2__'] == 'II'
        del os.environ['__test_key1__']
        del os.environ['__test_key2__']
Ejemplo n.º 4
0
def test_environ_keys():
    with Environ('myapp') as cfg:
        assert cfg.env.keys() == os.environ.keys()
Ejemplo n.º 5
0
def test_environ_items():
    with Environ('myapp') as cfg:
        assert cfg.env.items() == os.environ.items()
Ejemplo n.º 6
0
def test_environ_ne():
    with Environ('myapp') as cfg:
        return cfg.env != {}
Ejemplo n.º 7
0
def test_environ_eq():
    with Environ('myapp') as cfg:
        return cfg.env == os.environ
Ejemplo n.º 8
0
def test_environ_contains():
    with Environ('myapp') as cfg:
        os.environ['__test__'] = 'banana spiders'
        assert '__test__' in cfg.env
Ejemplo n.º 9
0
def test_environ_values():
    with Environ('myapp') as cfg:
        assert tuple(cfg.env.values()) == tuple(os.environ.values())
Ejemplo n.º 10
0
def test_environ_str():
    with Environ('myapp') as cfg:
        assert str(cfg.env) == str(os.environ)
Ejemplo n.º 11
0
def test_environ_len():
    with Environ('myapp') as cfg:
        assert len(cfg.env) == len(os.environ)
Ejemplo n.º 12
0
def test_environ_iter():
    with Environ('myapp') as cfg:
        assert tuple(iter(cfg.env)) == tuple(iter(os.environ))
Ejemplo n.º 13
0
def test_environ_key_error():
    with pytest.raises(DeleteEnvironVarError):
        with Environ('myapp') as cfg:
            del cfg.env['oops... what did you really expect to find in here?']
Ejemplo n.º 14
0
def test_environ_type_error():
    with pytest.raises(SetEnvironVarError):
        with Environ('myapp') as cfg:
            cfg.env[5] = None
Ejemplo n.º 15
0
def test_environ_setdefault():
    with Environ('myapp') as cfg:
        cfg.env.setdefault('some key', 'a value')
        assert cfg.env.get('some key2', 'a value2') == 'a value2'
Ejemplo n.º 16
0
def test_environ_pop():
    with Environ('myapp') as cfg:
        cfg.env['__test_key__'] = 'OK'
        assert os.environ['__test_key__'] == 'OK'
        assert cfg.env.pop('__test_key__') == 'OK'
        assert '__test_key__' not in os.environ
Ejemplo n.º 17
0
def test_environ_popitem():
    with Environ('myapp') as cfg:
        key, value = cfg.env.popitem()
        assert key not in os.environ
        os.environ[key] = value
Ejemplo n.º 18
0
def test_environ_repr():
    with Environ('myapp') as cfg:
        assert repr(cfg.env) == repr(os.environ)