示例#1
0
def test_concern_level():
	concern = Concern(CRITICAL, "This is a sample catastrophic failure.")
	assert concern.level == CRITICAL
	assert unicode(concern) == "This is a sample catastrophic failure."
	assert repr(concern) == 'Concern(CRITICAL, "This is a sample catastrophic failure.")'
	
	concern = Concern(WARNING, "This is a sample warning.")
	assert concern.level == WARNING
	assert unicode(concern) == "This is a sample warning."
	assert repr(concern) == 'Concern(WARNING, "This is a sample warning.")'
示例#2
0
	def test_deprecated_access(self):
		inst = self.Sample.from_mongo({'field': 'foo'})
		
		with warnings.catch_warnings(record=True) as w:
			warnings.simplefilter('always')
			
			assert inst.deprecated == 'foo'
			
			assert len(w) == 1
			assert issubclass(w[-1].category, DeprecationWarning)
			assert 'via deprecated' in unicode(w[-1].message)
			assert 'xyzzy' in unicode(w[-1].message)
示例#3
0
    def test_deprecated_access(self):
        inst = self.Sample.from_mongo({'field': 'foo'})

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')

            assert inst.deprecated == 'foo'

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'via deprecated' in unicode(w[-1].message)
            assert 'xyzzy' in unicode(w[-1].message)
示例#4
0
def test_concern_level():
    concern = Concern(CRITICAL, "This is a sample catastrophic failure.")
    assert concern.level == CRITICAL
    assert unicode(concern) == "This is a sample catastrophic failure."
    assert repr(
        concern
    ) == 'Concern(CRITICAL, "This is a sample catastrophic failure.")'

    concern = Concern(WARNING, "This is a sample warning.")
    assert concern.level == WARNING
    assert unicode(concern) == "This is a sample warning."
    assert repr(concern) == 'Concern(WARNING, "This is a sample warning.")'
示例#5
0
    def test_deprecated_assignment(self):
        inst = self.Sample()

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')

            inst.deprecated = 'bar'

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'via deprecated' in unicode(w[-1].message)
            assert 'xyzzy' in unicode(w[-1].message)

        assert inst.__data__ == {'field': 'bar'}
示例#6
0
	def test_deprecated_assignment(self):
		inst = self.Sample()
		
		with warnings.catch_warnings(record=True) as w:
			warnings.simplefilter('always')
			
			inst.deprecated = 'bar'
			
			assert len(w) == 1
			assert issubclass(w[-1].category, DeprecationWarning)
			assert 'via deprecated' in unicode(w[-1].message)
			assert 'xyzzy' in unicode(w[-1].message)
		
		assert inst.__data__ == {'field': 'bar'}
示例#7
0
 def test_raises(self):
     try:
         self.raises.validate(None)
     except Concern as e:
         assert unicode(e) == "Oh my no."
     else:
         assert False, "Failed to raise a Concern."
示例#8
0
	def test_raises(self):
		try:
			self.raises.validate(None)
		except Concern as e:
			assert unicode(e) == "Oh my no."
		else:
			assert False, "Failed to raise a Concern."
示例#9
0
	def _do(self, validator):
		assert validator.validate([1, 27, 42]) == [1, 27, 42]
		
		try:
			validator.validate([1, 2, 3])
		except Concern as e:
			assert unicode(e).startswith("Value does not contain: ")
		else:
			assert False, "Failed to raise a Concern."
示例#10
0
    def _do(self, validator):
        assert validator.validate([1, 27, 42]) == [1, 27, 42]

        try:
            validator.validate([1, 2, 3])
        except Concern as e:
            assert unicode(e).startswith("Value does not contain: ")
        else:
            assert False, "Failed to raise a Concern."
示例#11
0
def do_deprecation(value):
	cls, dst = value
	
	with warnings.catch_warnings(record=True) as w:
		warnings.simplefilter('always')
		
		cls()
		
		assert len(w) == 1, "Only one warning should be raised."
		assert issubclass(w[-1].category, DeprecationWarning), "Warning must be a DeprecationWarning."
		assert dst in unicode(w[-1].message), "Warning should mention correct class to use."
示例#12
0
def do_deprecation(value):
    cls, dst = value

    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')

        cls()

        assert len(w) == 1, "Only one warning should be raised."
        assert issubclass(
            w[-1].category,
            DeprecationWarning), "Warning must be a DeprecationWarning."
        assert dst in unicode(
            w[-1].message), "Warning should mention correct class to use."
示例#13
0
def test_depreciated_validation_import():
	with warnings.catch_warnings(record=True) as w:
		warnings.simplefilter('always')
		
		import marrow.schema.validation
		import marrow.schema.validation.base
		import marrow.schema.validation.compound
		import marrow.schema.validation.date
		import marrow.schema.validation.geo
		import marrow.schema.validation.network
		import marrow.schema.validation.pattern
		import marrow.schema.validation.testing
		import marrow.schema.validation.util
		
		assert len(w) == 1, "Only one warning should be raised."
		assert issubclass(w[-1].category, DeprecationWarning), "Warning must be DeprecationWarning."
		assert 'marrow.schema.validate' in unicode(w[-1].message), "Warning should mention correct module to import."
示例#14
0
def test_depreciated_validation_import():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')

        import marrow.schema.validation
        import marrow.schema.validation.base
        import marrow.schema.validation.compound
        import marrow.schema.validation.date
        import marrow.schema.validation.geo
        import marrow.schema.validation.network
        import marrow.schema.validation.pattern
        import marrow.schema.validation.testing
        import marrow.schema.validation.util

        assert len(w) == 1, "Only one warning should be raised."
        assert issubclass(
            w[-1].category,
            DeprecationWarning), "Warning must be DeprecationWarning."
        assert 'marrow.schema.validate' in unicode(
            w[-1].message), "Warning should mention correct module to import."
示例#15
0
def test_basic_concern_text_replacement():
    concern = Concern("{who} has failed me for the {times} time.",
                      who="Bob Dole",
                      times="last")
    assert unicode(concern) == "Bob Dole has failed me for the last time."
示例#16
0
文件: test_q.py 项目: bb78657/mongo
 def test_operator_invert(self):
     assert unicode(Sample.generic) == ~Sample.generic == 'generic'
示例#17
0
	def test_concern(self):
		try:
			self.transform('x')
		except Concern as e:
			assert self.direction in unicode(e)
			assert 'invalid literal' in unicode(e)
示例#18
0
	def test_native_conversion(self, Sample):
		inst = Sample.from_mongo({'field': '/foo'})
		value = inst.field
		assert isinstance(value, _Path)
		assert unicode(value) == '/foo'
示例#19
0
def test_basic_concern_text():
	concern = Concern("This is a sample failure.")
	assert unicode(concern) == "This is a sample failure."
示例#20
0
文件: test_q.py 项目: marrow/mongo
	def test_operator_invert(self):
		assert unicode(Sample.generic) == ~Sample.generic == 'generic'
示例#21
0
def test_basic_concern_positional_replacement():
	concern = Concern("{0} has failed me for the {1} time.", "Bob Dole", "last")
	assert unicode(concern) == "Bob Dole has failed me for the last time."
示例#22
0
文件: test_q.py 项目: marrow/mongo
	def test_s(self):
		assert unicode(Sample.array.S) == 'field_name.$'
示例#23
0
def test_basic_concern_text_replacement():
	concern = Concern("{who} has failed me for the {times} time.", who="Bob Dole", times="last")
	assert unicode(concern) == "Bob Dole has failed me for the last time."
示例#24
0
def test_basic_concern_text():
    concern = Concern("This is a sample failure.")
    assert unicode(concern) == "This is a sample failure."
示例#25
0
文件: test_q.py 项目: marrow/mongo
	def test_embedded(self):
		assert unicode(Sample.embed.name) == 'embed.name'
示例#26
0
文件: test_q.py 项目: bb78657/mongo
 def test_embedded(self):
     assert unicode(Sample.embed.name) == 'embed.name'
示例#27
0
	def test_cast_string(self, Sample):
		inst = Sample('5832223f927cc6c1a10609f7')
		
		assert isinstance(inst.__data__['field'], oid)
		assert unicode(inst.field) == '5832223f927cc6c1a10609f7'
示例#28
0
def test_basic_concern_positional_replacement():
    concern = Concern("{0} has failed me for the {1} time.", "Bob Dole",
                      "last")
    assert unicode(concern) == "Bob Dole has failed me for the last time."
示例#29
0
文件: test_q.py 项目: bb78657/mongo
 def test_s(self):
     assert unicode(Sample.array.S) == 'field_name.$'