Skip to content

Commit

Permalink
fix tests (Lightning-AI#938)
Browse files Browse the repository at this point in the history
* fix tests

* fix tests
  • Loading branch information
williamFalcon authored and tullie committed Apr 3, 2020
1 parent 8b25d8c commit 51e2fb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pytorch_lightning/trainer/evaluation_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def evaluate(self, model, dataloaders, max_batches, test=False):

def run_evaluation(self, test=False):
# when testing make sure user defined a test step
if test and not (self.is_overriden('test_step') or self.is_overriden('test_end')):
m = '''You called `.test()` without defining model's `.test_step()` or `.test_end()`.
if test and not self.is_overriden('test_step'):
m = '''You called `.test()` without defining model's `.test_step()`.
Please define and try again'''
raise MisconfigurationException(m)

Expand Down
10 changes: 0 additions & 10 deletions tests/test_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,22 +793,12 @@ def test_step(self, *args, **kwargs):
def test_dataloader(self):
return self.train_dataloader()

class TestModelNoStep(LightningTestModelBase):
def test_end(self, outputs):
return {}

def test_dataloader(self):
return self.train_dataloader()

# Misconfig when neither test_step or test_end is implemented
with pytest.raises(MisconfigurationException):
model = LightningTestModelBase(hparams)
Trainer().test(model)

# No exceptions when one or both of test_step or test_end are implemented
model = TestModelNoStep(hparams)
Trainer().test(model)

model = TestModelNoEnd(hparams)
Trainer().test(model)

Expand Down

0 comments on commit 51e2fb3

Please sign in to comment.