Mercurial > boomslang
diff pyntnclick/tests/test_resources.py @ 854:79b5c1be9a5e default tip
Remove pyntnclick, it's its own library, now
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 21 Jun 2014 22:06:09 +0200 |
parents | f95830b58336 |
children |
line wrap: on
line diff
--- a/pyntnclick/tests/test_resources.py Sat Jun 21 22:04:35 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -import os.path -from unittest import TestCase - -from pygame.surface import Surface - -from pyntnclick.resources import Resources, ResourceNotFound - - -TEST_PATH = os.path.dirname(__file__) -DATA_PATH = os.path.join(os.path.dirname(TEST_PATH), 'data') - -test_path = lambda p: os.path.join(TEST_PATH, p) -data_path = lambda p: os.path.join(DATA_PATH, p) - - -class ResourcesTestCase(TestCase): - def setUp(self): - self.res = self.get_resource_loader() - - def get_resource_loader(self, *args, **kw): - res = Resources('pyntnclick.tests', *args, **kw) - res.CONVERT_ALPHA = False # Because we have no display. - return res - - def test_get_paths_no_lang(self): - self.assertEqual([test_path('thing'), data_path('thing')], - self.res.get_paths('thing')) - - def test_get_paths_lang(self): - res = self.get_resource_loader('en') - self.assertEqual([test_path('en/thing'), test_path('thing'), - data_path('en/thing'), data_path('thing')], - res.get_paths('thing')) - - def test_get_paths_lang_dialect(self): - res = self.get_resource_loader('en_ZA') - self.assertEqual([test_path('en_ZA/thing'), test_path('en/thing'), - test_path('thing'), data_path('en_ZA/thing'), - data_path('en/thing'), data_path('thing')], - res.get_paths('thing')) - - def test_get_resource_path_missing(self): - try: - self.res.get_resource_path('should_not_exist') - self.fail('Expected ResourceNotFound error.') - except ResourceNotFound, e: - self.assertEqual('should_not_exist', e.args[0]) - - def test_get_resource_path_in_test(self): - self.assertEqual(test_path('test_resources.py'), - self.res.get_resource_path('test_resources.py')) - - def test_get_resource_path_in_data(self): - self.assertEqual( - data_path('images/pyntnclick/hand.png'), - self.res.get_resource_path('images/pyntnclick/hand.png')) - - def test_get_image(self): - image = self.res.get_image('pyntnclick/hand.png') - self.assertTrue(isinstance(image, Surface)) - - def test_get_image_fragments(self): - image = self.res.get_image('pyntnclick', 'hand.png') - self.assertTrue(isinstance(image, Surface)) - - def test_get_image_different_basedir(self): - image = self.res.get_image('hand.png', basedir='images/pyntnclick') - self.assertTrue(isinstance(image, Surface)) - - def test_load_missing(self): - try: - self.res.get_image('should_not_exist') - self.fail('Expected ResourceNotFound error.') - except ResourceNotFound, e: - self.assertEqual('images/should_not_exist', e.args[0])