test_data.py 680 B

12345678910111213141516171819202122
  1. import unittest
  2. import nltk.data
  3. from nose.tools import assert_raises
  4. class TestData(unittest.TestCase):
  5. def test_find_raises_exception(self):
  6. with assert_raises(LookupError) as context:
  7. nltk.data.find('no_such_resource/foo')
  8. assert type(context.exception) == LookupError, 'Unexpected exception raised'
  9. def test_find_raises_exception_with_full_resource_name(self):
  10. no_such_thing = 'no_such_thing/bar'
  11. with assert_raises(LookupError) as context:
  12. nltk.data.find(no_such_thing)
  13. assert no_such_thing in str(
  14. context.exception
  15. ), 'Exception message does not include full resource name'