Example #1
0
def test_apply_sca():
  env = {'x': '1', 'PATH': os.pathsep.join(['orig', 'paths'])}
  e = EnvDelta(scalars={'x': '2', 'y': 'fun/paths'})
  exp = {'x': '2', 'PATH': os.pathsep.join(['orig', 'paths']), 'y': 'fun/paths',
         _undo_key: repr(e)}
  obs = e.apply(env)
  assert_equal(exp, obs)
Example #2
0
def test_apply_sca_with_undo():
  env = {'x': '1', 'PATH': os.pathsep.join(['orig', 'paths'])}
  e = EnvDelta(scalars={'x': '2', 'y': 'fun/paths'})
  env = e.apply(env)
  f = EnvDelta(scalars={'x': '3', 'z': 'machine'})
  exp = {'x': '3', 'PATH': os.pathsep.join(['orig', 'paths']), 'y': 'fun/paths',
         'z': 'machine', _undo_key: repr(f)}
  obs = f.apply(env)
  assert_equal(exp, obs)
Example #3
0
def test_apply_iter_with_undo():
  env = {'x': '1', 'PATH': os.pathsep.join(['orig', 'paths'])}
  e = EnvDelta.fromiter('PATH', ['my', 'fun/paths'])
  env = e.apply(env)
  f = EnvDelta.fromiter('PATH', ['truth', 'lies'])
  exp = {'x': '1', 'PATH': os.pathsep.join(['lies', 'truth', 
         'fun/paths', 'my', 'orig', 'paths']), _undo_key: repr(f)}
  obs = f.apply(env)
  assert_equal(exp, obs)
Example #4
0
def test_apply_iter():
  env = {'x': '1', 'PATH': os.pathsep.join(['orig', 'paths'])}
  e = EnvDelta.fromiter('PATH', ['my', 'fun/paths'])
  exp = {'x': '1', 'PATH': os.pathsep.join(['fun/paths', 'my', 'orig', 'paths']),
         _undo_key: repr(e)}
  obs = e.apply(env)
  assert_equal(exp, obs)
Example #5
0
def test_merge_set_bad():
  e = EnvDelta.fromiter('x', range(10))
  f = EnvDelta.fromiter('x', range(11))
  e.merge(f)
  o = EnvDelta(sets={'x': set(range(11))})
  assert_equal(e, o)
Example #6
0
def test_merge_set_sca_bad():
  e = EnvDelta.fromiter('x', range(10))
  f = EnvDelta.fromscalar('x', 'YYY')
  assert_raises(AssertionError, e.merge, f)
Example #7
0
def test_merge_set_sca():
  e = EnvDelta.fromiter('x', range(10))
  f = EnvDelta.fromscalar('y', 'YYY')
  e.merge(f)
  o = EnvDelta(sets={'x': set(range(10))}, scalars={'y': 'YYY'})
  assert_equal(e, o)
Example #8
0
def test_merge_sca_bad():
  e = EnvDelta.fromscalar('x', 'XXX')
  f = EnvDelta.fromscalar('x', 'YYY')
  assert_raises(AssertionError, e.merge, f)
Example #9
0
def test_fromiter():
  e = EnvDelta.fromiter('x', range(10))
  o = EnvDelta(sets={'x': set(range(10))})
  assert_equal(e, o)
Example #10
0
def test_merge_sca():
  e = EnvDelta.fromscalar('x', 'XXX')
  f = EnvDelta.fromscalar('y', 'YYY')
  e.merge(f)
  o = EnvDelta(scalars={'x': 'XXX', 'y': 'YYY'})
  assert_equal(e, o)
Example #11
0
def test_define_other():
  e = EnvDelta.fromscalar('x', 'XXX')
  e.define('y', 'YYY')
  o = EnvDelta(scalars={'x': 'XXX', 'y': 'YYY'})
  assert_equal(e, o)
Example #12
0
def test_define():
  e = EnvDelta.fromscalar('x', 'XXX')
  e.define('x', 'XXX')
  o = EnvDelta(scalars={'x': 'XXX'})
  assert_equal(e, o)
Example #13
0
def test_add_other():
  e = EnvDelta.fromiter('x', range(10))
  e.add('y', range(11))
  o = EnvDelta(sets={'x': set(range(10)), 'y': set(range(11))})
  assert_equal(e, o)