Skip to content

Commit

Permalink
try fix broken tests due to ambiguous process ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy committed Aug 1, 2017
1 parent cfb01d5 commit a63fec4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 7 additions & 2 deletions xsimlab/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ def other_derived_quantity(self):

class SomeProcess(Process):
some_param = Variable((), description='some parameter')
copy_param = Variable((), provided=True)
x = ForeignVariable(Grid, 'x')
quantity = ForeignVariable(Quantity, 'quantity')
some_effect = Variable('x', group='effect', provided=True)

# SomeProcess always appears before OtherProcess in a model
copy_param = Variable((), provided=True)

def initialize(self):
self.copy_param.value = self.some_param.value

Expand All @@ -103,10 +105,12 @@ def finalize(self):

class OtherProcess(Process):
x = ForeignVariable(Grid, 'x')
copy_param = ForeignVariable(SomeProcess, 'copy_param')
quantity = ForeignVariable(Quantity, 'quantity')
other_effect = Variable('x', group='effect', provided=True)

# OtherProcess should always appear after SomeProcess in a model
copy_param = ForeignVariable(SomeProcess, 'copy_param')

def run_step(self, dt):
self.other_effect.value = self.x.value * self.copy_param.value - dt

Expand All @@ -118,6 +122,7 @@ def x2(self):
class PlugProcess(Process):
meta_param = Variable(())
some_param = ForeignVariable(SomeProcess, 'some_param', provided=True)
x = ForeignVariable(Grid, 'x')

def run_step(self, *args):
self.some_param.value = self.meta_param.value
Expand Down
2 changes: 0 additions & 2 deletions xsimlab/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ def test_update_processes(self, model):
'other_process': OtherProcess,
'quantity': Quantity})
actual = model.update_processes({'plug_process': PlugProcess})

# TODO: more advanced (public?) test function to compare two models?
assert list(actual) == list(expected)

def test_drop_processes(self, model):
Expand Down

0 comments on commit a63fec4

Please sign in to comment.