示例#1
0
 def test_can_detect_utf16_as_non_binary(self):
     test_path = _test_path("utf-16")
     with open(test_path, "w", encoding="utf-16") as test_file:
         test_file.write("Hello world!")
     assert not analysis.is_binary_file(test_path)
示例#2
0
 def test_can_detect_binary_with_zero_byte(self):
     test_path = _test_path("binary")
     with open(test_path, "wb") as test_file:
         test_file.write(b"hello\0world")
     assert analysis.is_binary_file(test_path)
示例#3
0
 def test_can_detect_utf16_as_non_binary(self):
     test_path = self.create_temp_file("utf-16", "Hello world!", "utf-16")
     assert not analysis.is_binary_file(test_path)
示例#4
0
 def test_can_detect_binary_with_zero_byte(self):
     test_path = self.create_temp_binary_file("binary", b"hello\0world")
     assert analysis.is_binary_file(test_path)
示例#5
0
 def test_can_detect_utf16_as_non_binary(self):
     test_path = _test_path('utf-16')
     with open(test_path, 'w', encoding='utf-16') as test_file:
         test_file.write('Hello world!')
     self.assertFalse(analysis.is_binary_file(test_path))
示例#6
0
 def test_can_detect_binary_with_zero_byte(self):
     test_path = _test_path('binary')
     with open(test_path, 'wb') as test_file:
         test_file.write(b'hello\0world')
     self.assertTrue(analysis.is_binary_file(test_path))