class CoreTestSuite(ImagyTestCase): def setup(self): self.s = Store() self.copy_images_over() def check_image(self, img): img = self.img_path(img) sz = img.size optimize_with_touch(img) self.assertTrue(sz >= img.size) def test_store_original(self): img = self.img_path('jpg') orig = store_original(img) self.assertTrue(same_file(img, orig)) orig.remove() def test_make_path(self): self.assertFalse(make_path(__file__).exists()) def test_clear(self): thing = 'thing' self.s.originals[thing] = '' self.s.clear() self.s.save() self.assertFalse(thing in self.s.originals)
def setup(self): self.s = Store() self.copy_images_over()
to work around watchdog picking up modified file paths at an indeterminate point in time, we maintain a counter of how many times to ignore it e.g. if we create a new file in a directory that watchdog is watching we can expect to receive 2 events, file_created and file_modified and increase its counter to 2 ''' counter = self.ignored[pth] if counter < 0: # ignore indefinitely return False elif counter > 0: self.ignored[pth] -= 1 return False # 0 default case return True store = Store() ########NEW FILE######## __FILENAME__ = context import sys, os sys.path.insert(0, os.path.abspath('../..')) import imagy reload(imagy) ########NEW FILE######## __FILENAME__ = imgtest from __future__ import division from path import path from subprocess import Popen, call