Here are the examples of the python api pytest.mark.conversion taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
3
Example 1
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_ensure_byte_string():
assert isinstance(_util.ensure_byte_string('hello world'), bytes)
assert _util.ensure_byte_string('hello world') == b'hello world'
hello = b'hello world'
assert _util.ensure_byte_string(hello) is hello
3
Example 2
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_ensure_unicode_string():
assert is_unicode_string(
_util.ensure_unicode_string(b'hello world'))
assert _util.ensure_unicode_string(b'hello world') == 'hello world'
hello = 'hello world'
assert _util.ensure_unicode_string(hello) is hello
3
Example 3
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_property_value_to_bytes_string():
hello = 'hello world'.encode(sys.getfilesystemencoding())
assert _util.property_value_to_bytes(hello) is hello
assert isinstance(_util.property_value_to_bytes('hello world'), bytes)
assert _util.property_value_to_bytes('hello world') == hello
3
Example 4
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_property_value_to_bytes_bool():
assert _util.property_value_to_bytes(True) == b'1'
assert isinstance(_util.property_value_to_bytes(True), bytes)
assert _util.property_value_to_bytes(False) == b'0'
assert isinstance(_util.property_value_to_bytes(False), bytes)
0
Example 5
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_ensure_byte_string_none():
with pytest.raises(AttributeError):
_util.ensure_byte_string(None)
0
Example 6
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_ensure_unicode_string_none():
with pytest.raises(AttributeError):
_util.ensure_unicode_string(None)
0
Example 7
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_property_value_to_bytes_int():
assert _util.property_value_to_bytes(10000) == b'10000'
assert isinstance(_util.property_value_to_bytes(10000), bytes)
0
Example 8
@pytest.mark.conversion
def test_string_to_bool_true():
assert isinstance(_util.string_to_bool('1'), bool)
assert _util.string_to_bool('1')
0
Example 9
@pytest.mark.conversion
def test_string_to_bool_false():
assert isinstance(_util.string_to_bool('0'), bool)
assert not _util.string_to_bool('0')
0
Example 10
Project: pyudev Source File: test_util.py
@pytest.mark.conversion
def test_string_to_bool_invalid_value():
with pytest.raises(ValueError) as exc_info:
_util.string_to_bool('foo')
assert str(exc_info.value) == 'Not a boolean value: {0!r}'.format('foo')