Skip to content

Commit da5afd1

Browse files
committed
Testing for reproducibility
1 parent 8cd23fb commit da5afd1

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/test_utils.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
_nested_replace_type,
1919
define_python_object_encoder,
2020
UnpicklableObject,
21-
as_python_object
21+
as_python_object,
22+
enforce_reproducibility,
2223
)
2324

2425

@@ -454,5 +455,32 @@ def __init__(self):
454455
self.assertEqual(recreated_obj, expected_obj)
455456

456457

458+
class EnforceReproducibilityTests(TestCase):
459+
460+
def test_saved_reproducibility_data_is_none(self):
461+
with self.assertRaises(ValueError):
462+
enforce_reproducibility(None, {}, 'here')
463+
464+
def test_git_url_not_in_saved_reproducibility_data(self):
465+
with self.assertRaises(ValueError):
466+
enforce_reproducibility({}, {}, 'here')
467+
468+
def test_git_url_not_in_current_reproducibility_data(self):
469+
with self.assertRaises(ValueError):
470+
enforce_reproducibility({'git_url': 'none'}, {}, 'here')
471+
472+
def test_git_urls_disagree(self):
473+
with self.assertRaises(ValueError):
474+
enforce_reproducibility({'git_url': 'none'}, {'git_url': 'some'}, 'here')
475+
476+
def test_throw_error_for_saved_uncommitted_changes(self):
477+
with self.assertRaises(ValueError):
478+
enforce_reproducibility({'git_url': 'none', 'git_has_uncommitted_changes': True}, {'git_url': 'some'}, 'here')
479+
480+
def test_throw_error_for_uncommitted_changes(self):
481+
with self.assertRaises(ValueError):
482+
enforce_reproducibility({'git_url': 'none', 'git_has_uncommitted_changes': False}, {'git_url': 'some', 'git_has_uncommitted_changes': True}, 'here')
483+
484+
457485
if __name__ == '__main__':
458486
unittest.main()

0 commit comments

Comments
 (0)