コード例 #1
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_python_not_str(self):
     field = BytesField(name='asdf')
     with pytest.raises(ValueError):
         field.to_python(MockConfig(), 100)
コード例 #2
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_basic_hex(self):
     field = BytesField('hex')
     assert field.to_basic(MockConfig(), b'hello') == b'hello'.hex()
コード例 #3
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_python_none(self):
     field = BytesField()
     assert field.to_python(MockConfig(), None) is None
コード例 #4
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_basic_none(self):
     field = BytesField(name='asdf')
     field.to_basic(MockConfig(), None) is None
コード例 #5
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_basic_base64(self):
     field = BytesField('base64')
     assert field.to_basic(MockConfig(), b'hello') == base64.b64encode(b'hello').decode()
コード例 #6
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_python_hex_invalid(self):
     field = BytesField('hex')
     with pytest.raises(ValueError):
         field.to_python(MockConfig(), 'hello')
コード例 #7
0
ファイル: test_bytes.py プロジェクト: Burrch3s/cincoconfig
 def test_to_basic_none(self):
     field = BytesField(name='asdf')
     field.to_basic(None, None) is None
コード例 #8
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_init_invalid_encoding(self):
     with pytest.raises(TypeError):
         BytesField('asdf')
コード例 #9
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_validate_str(self):
     field = BytesField()
     field._validate(MockConfig(), 'hello') == b'hello'
コード例 #10
0
ファイル: test_bytes.py プロジェクト: Burrch3s/cincoconfig
 def test_to_python_base64_invalid(self):
     field = BytesField('base64')
     with pytest.raises(ValueError):
         field.to_python(None, 'hello')
コード例 #11
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_init_valid_encoding(self):
     field = BytesField('hex')
     assert field.encoding == 'hex'
コード例 #12
0
ファイル: test_bytes.py プロジェクト: Burrch3s/cincoconfig
 def test_to_python_none(self):
     field = BytesField()
     assert field.to_python(None, None) is None
コード例 #13
0
ファイル: test_bytes.py プロジェクト: Burrch3s/cincoconfig
 def test_to_basic_invalid(self):
     field = BytesField(name='asdf')
     field.encoding = 'adsf'
     with pytest.raises(TypeError):
         field.to_basic(None, 'asdf')
コード例 #14
0
ファイル: test_bytes.py プロジェクト: Burrch3s/cincoconfig
 def test_to_basic_hex(self):
     field = BytesField('hex')
     assert field.to_basic(None, b'hello') == b'hello'.hex()
コード例 #15
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_python_base64_valid(self):
     field = BytesField('base64')
     assert field.to_python(MockConfig(), base64.b64encode(b'hello').decode()) == b'hello'
コード例 #16
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_validate_bytes(self):
     field = BytesField()
     assert field._validate(None, b'hello') == b'hello'
コード例 #17
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_python_hex_valid(self):
     field = BytesField('hex')
     assert field.to_python(MockConfig(), 'deadbeef') == b'\xde\xad\xbe\xef'
コード例 #18
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_validate_invalid_type(self):
     field = BytesField(name='asdf')
     with pytest.raises(ValueError):
         field._validate(MockConfig(), 100)
コード例 #19
0
ファイル: test_bytes.py プロジェクト: ameily/cincoconfig
 def test_to_python_invalid(self):
     field = BytesField(name='asdf')
     field.encoding = 'adsf'
     with pytest.raises(TypeError):
         field.to_python(MockConfig(), 'asdf')
コード例 #20
0
ファイル: test_bytes.py プロジェクト: Burrch3s/cincoconfig
 def test_validate_str(self):
     field = BytesField()
     field._validate(None, 'hello') == b'hello'