test_reader.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. """
  2. Contains tests class for reader.py
  3. """
  4. #-----------------------------------------------------------------------------
  5. # Copyright (C) 2013 The IPython Development Team
  6. #
  7. # Distributed under the terms of the BSD License. The full license is in
  8. # the file COPYING, distributed as part of this software.
  9. #-----------------------------------------------------------------------------
  10. #-----------------------------------------------------------------------------
  11. # Imports
  12. #-----------------------------------------------------------------------------
  13. from .base import TestsBase
  14. from ..reader import read, get_version
  15. #-----------------------------------------------------------------------------
  16. # Classes and functions
  17. #-----------------------------------------------------------------------------
  18. class TestReader(TestsBase):
  19. def test_read(self):
  20. """Can older notebooks be opened without modification?"""
  21. # Open a version 3 notebook. Make sure it is still version 3.
  22. with self.fopen(u'test3.ipynb', u'r') as f:
  23. nb = read(f)
  24. (major, minor) = get_version(nb)
  25. self.assertEqual(major, 3)
  26. # Open a version 2 notebook. Make sure it is still version 2.
  27. with self.fopen(u'test2.ipynb', u'r') as f:
  28. nb = read(f)
  29. (major, minor) = get_version(nb)
  30. self.assertEqual(major, 2)