def memoize_test(self): composite = enum('composite') self.assertEqual(enum('qwerty'), enum('qwerty')) self.assertEqual(composite.qwerty, composite.qwerty) self.assertEqual(id(composite.qwerty), id(composite.qwerty)) self.assertNotEqual(composite.qwerty, composite.abc)
def test(self): composite = enum('composite') self.assertEqual( lookup(composite.non_existant, version=(6, 6), throw=False), None) self.assertRaisesRegexp( PystaciaException, 'cannot map mnemonic', lambda: lookup(composite.non_existant, version=(6, 0))) self.assertEqual(lookup(composite.undefined, version=(6, 6, 2, 10)), 0) self.assertEqual( lookup(composite.undefined, version=(2, 6), throw=False), None) self.assertEqual(lookup(composite.undefined, version=(6, 7, 2, 8)), 0) self.assertEqual( lookup(composite.darken_intensity, version=(6, 7, 2, 1)), 66) self.assertEqual(lookup('undefined', composite, version=(6, 6, 2, 10)), 0)
def cast_test(self): xyz = cast('abc', 'xyz') self.assertEqual(xyz.name, 'xyz') self.assertEqual(xyz.enum.name, 'abc') self.assertEqual(xyz.enum, enum('abc')) self.assertEqual(cast(xyz.enum, 'xyz'), xyz.enum.xyz) self.assertRaisesRegexp(PystaciaException, 'Cannot cast', lambda: cast(2, 'asd')) self.assertRaisesRegexp(PystaciaException, 'Attempted to cast', lambda: cast(xyz.enum, cast('fgh', 'rty'))) self.assertEqual(id(xyz), id(cast(xyz.enum, xyz))) self.assertRaisesRegexp(PystaciaException, 'Cannot cast', lambda: cast('asd', 2)) self.assertRaisesRegexp(PystaciaException, 'Cannot cast', lambda: xyz.enum.cast(1))
def test(self): composite = enum('composite') self.assertEqual(lookup(composite.non_existant, version=(6, 6), throw=False), None) self.assertRaisesRegexp(PystaciaException, 'cannot map mnemonic', lambda: lookup(composite.non_existant, version=(6, 0))) self.assertEqual(lookup(composite.undefined, version=(6, 6, 2, 10)), 0) self.assertEqual(lookup(composite.undefined, version=(2, 6), throw=False), None) self.assertEqual(lookup(composite.undefined, version=(6, 7, 2, 8)), 0) self.assertEqual(lookup(composite.darken_intensity, version=(6, 7, 2, 1)), 66) self.assertEqual(lookup('undefined', composite, version=(6, 6, 2, 10)), 0)
# coding: utf-8 # pystacia/image/enum.py # Copyright (C) 2011-2012 by Paweł Piotr Przeradowski # This module is part of Pystacia and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from pystacia.lazyenum import enum types = enum('type') filters = enum('filter') colorspaces = enum('colorspace') compressions = enum('compression') composites = enum('composite') axes = enum('axis') metrics = enum('metric') noises = enum('noise') thresholds = enum('threshold') interpolations = enum('interpolation') operations = enum('operation') fit_modes = enum('mode')
def name_test(self): composite = enum('composite') self.assertEqual(composite.name, 'composite') self.assertEqual(composite.atop.name, 'atop')