
import os
import io
import sys
import unittest

# Hack to support the usage of `coverage`
sys.path.append(os.path.abspath("."))

import lbuild


class RepositoryTest(unittest.TestCase):

    def _get_path(self, filename):
        return os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "resources", "repository", filename)

    def setUp(self):
        self.parser = lbuild.parser.Parser()

    def test_should_generate_exception_on_import_error(self):
        with self.assertRaises(lbuild.exception.BlobForwardException) as cm:
            self.parser.parse_repository(self._get_path("invalid_import.lb"))

        self.assertEqual(ModuleNotFoundError, cm.exception.exception.__class__)


if __name__ == '__main__':
    unittest.main()


import os
import sys
import unittest

# Hack to support the usage of `coverage`
sys.path.append(os.path.abspath("."))

import lbuild


class RepositoryTest(unittest.TestCase):

    def _get_path(self, filename):
        return os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "resources", "repository", filename)

    def setUp(self):
        self.parser = lbuild.parser.Parser()

    def test_should_generate_exception_on_import_error(self):
        with self.assertRaises(lbuild.exception.BlobForwardException) as cm:
            self.parser.parse_repository(self._get_path("invalid_import.lb"))

        self.assertTrue(issubclass(cm.exception.exception.__class__, ImportError))


if __name__ == '__main__':
    unittest.main()

Fix repository import test for Python < 3.6
Fix repository import test for Python < 3.6

Check for broader range of exceptions.

  
  import os
- import io
  import sys
  import unittest
  
  # Hack to support the usage of `coverage`
  sys.path.append(os.path.abspath("."))
  
  import lbuild
  
  
  class RepositoryTest(unittest.TestCase):
  
      def _get_path(self, filename):
          return os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              "resources", "repository", filename)
  
      def setUp(self):
          self.parser = lbuild.parser.Parser()
  
      def test_should_generate_exception_on_import_error(self):
          with self.assertRaises(lbuild.exception.BlobForwardException) as cm:
              self.parser.parse_repository(self._get_path("invalid_import.lb"))
  
-         self.assertEqual(ModuleNotFoundError, cm.exception.exception.__class__)
+         self.assertTrue(issubclass(cm.exception.exception.__class__, ImportError))
  
  
  if __name__ == '__main__':
      unittest.main()
  
Fix repository import test for Python < 3.6
## Code Before:

import os
import io
import sys
import unittest

# Hack to support the usage of `coverage`
sys.path.append(os.path.abspath("."))

import lbuild


class RepositoryTest(unittest.TestCase):

    def _get_path(self, filename):
        return os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "resources", "repository", filename)

    def setUp(self):
        self.parser = lbuild.parser.Parser()

    def test_should_generate_exception_on_import_error(self):
        with self.assertRaises(lbuild.exception.BlobForwardException) as cm:
            self.parser.parse_repository(self._get_path("invalid_import.lb"))

        self.assertEqual(ModuleNotFoundError, cm.exception.exception.__class__)


if __name__ == '__main__':
    unittest.main()

## Instruction:
Fix repository import test for Python < 3.6
## Code After:

import os
import sys
import unittest

# Hack to support the usage of `coverage`
sys.path.append(os.path.abspath("."))

import lbuild


class RepositoryTest(unittest.TestCase):

    def _get_path(self, filename):
        return os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "resources", "repository", filename)

    def setUp(self):
        self.parser = lbuild.parser.Parser()

    def test_should_generate_exception_on_import_error(self):
        with self.assertRaises(lbuild.exception.BlobForwardException) as cm:
            self.parser.parse_repository(self._get_path("invalid_import.lb"))

        self.assertTrue(issubclass(cm.exception.exception.__class__, ImportError))


if __name__ == '__main__':
    unittest.main()
