<s> import six <EOL> if six . PY3 : <EOL> import unittest <EOL> else : <EOL> import unittest2 as unittest <EOL> from depsolver . bundled . traitlets import HasTraits , TraitError <EOL> from depsolver . errors import DepSolverError <EOL> from depsolver . utils import Callable , CachedScheduler , Scheduler <EOL> class TestScheduler ( unittest . TestCase ) : <EOL> def test_simple ( self ) : <EOL> scheduler = Scheduler ( ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( scheduler . order ( "<STR_LIT>" ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_after ( self ) : <EOL> scheduler = Scheduler ( ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( scheduler . order ( "<STR_LIT>" ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_before ( self ) : <EOL> scheduler = Scheduler ( ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , before = "<STR_LIT>" ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , before = "<STR_LIT>" ) <EOL> self . assertEqual ( scheduler . order ( "<STR_LIT>" ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_cycle ( self ) : <EOL> scheduler = Scheduler ( ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , before = "<STR_LIT>" ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , before = "<STR_LIT>" ) <EOL> self . assertRaises ( DepSolverError , lambda : scheduler . order ( "<STR_LIT>" ) ) <EOL> def test_compute_priority ( self ) : <EOL> r_priority = dict ( ( name , i ) for i , name in enumerate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> scheduler = Scheduler ( ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , before = "<STR_LIT>" ) <EOL> self . assertEqual ( scheduler . compute_priority ( ) , r_priority ) <EOL> class TestCachedScheduler ( unittest . TestCase ) : <EOL> def test_simple ( self ) : <EOL> r_priority = dict ( ( name , i ) for i , name in enumerate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> scheduler = CachedScheduler ( ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , before = "<STR_LIT>" ) <EOL> self . assertEqual ( scheduler . compute_priority ( ) , r_priority ) <EOL> self . assertFalse ( scheduler . invalidated ) <EOL> scheduler . set_constraints ( "<STR_LIT>" , after = "<STR_LIT>" ) <EOL> self . assertTrue ( scheduler . invalidated ) <EOL> r_priority = dict ( ( name , i ) for i , name in enumerate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( scheduler . compute_priority ( ) , r_priority ) <EOL> class TestCallableTrait ( unittest . TestCase ) : <EOL> def test_simple ( self ) : <EOL> class Foo ( HasTraits ) : <EOL> func = Callable ( ) <EOL> foo = Foo ( ) <EOL> self . assertRaises ( TraitError , lambda : Foo ( func = "<STR_LIT>" ) ) </s>
