Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
chardet==3.0.4
nose==1.3.7
tox==3.20.1
Cython==0.29.21
# pylint==2.6.0
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[nosetests]
verbose=1
nocapture=1
32 changes: 7 additions & 25 deletions src/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import string

from nose.tools import eq_
import cchardet

SKIP_LIST = [
Expand All @@ -26,14 +25,11 @@
class TestCChardet():
def test_ascii(self):
detected_encoding = cchardet.detect(b'abcdefghijklmnopqrstuvwxyz')
eq_(
'ascii',
detected_encoding['encoding'].lower(),
assert 'ascii' == detected_encoding['encoding'].lower(), \
'Expected %s, but got %s' % (
'ascii',
detected_encoding['encoding'].lower()
)
)

def test_detect(self):
testfiles = glob.glob('tests/testdata/*/*.txt')
Expand All @@ -46,15 +42,13 @@ def test_detect(self):
with open(testfile, 'rb') as f:
msg = f.read()
detected_encoding = cchardet.detect(msg)
eq_(
expected_charset.lower(),
detected_encoding['encoding'].lower(),
assert expected_charset.lower() == \
detected_encoding['encoding'].lower(), \
'Expected %s, but got %s for "%s"' % (
expected_charset.lower(),
detected_encoding['encoding'].lower(),
testfile
)
)

def test_detector(self):
detector = cchardet.UniversalDetector()
Expand All @@ -67,14 +61,11 @@ def test_detector(self):
line = f.readline()
detector.close()
detected_encoding = detector.result
eq_(
"shift_jis",
detected_encoding['encoding'].lower(),
assert "shift_jis" == detected_encoding['encoding'].lower(), \
'Expected %s, but got %s' % (
"shift_jis",
detected_encoding['encoding'].lower()
)
)

def test_github_issue_20(self):
"""
Expand Down Expand Up @@ -109,37 +100,28 @@ def test_decode(self):
def test_utf8_with_bom(self):
sample = b'\xEF\xBB\xBF'
detected_encoding = cchardet.detect(sample)
eq_(
"utf-8-sig",
detected_encoding['encoding'].lower(),
assert "utf-8-sig" == detected_encoding['encoding'].lower(), \
'Expected %s, but got %s' % (
"utf-8-sig",
detected_encoding['encoding'].lower()
)
)

def test_null_bytes(self):
sample = b'ABC\x00\x80\x81'
detected_encoding = cchardet.detect(sample)

eq_(
None,
detected_encoding['encoding'],
assert detected_encoding['encoding'] is None, \
'Expected None, but got %s' % (
detected_encoding['encoding']
)
)

# def test_iso8859_2_csv(self):
# testfile = 'tests/samples/iso8859-2.csv'
# with open(testfile, 'rb') as f:
# msg = f.read()
# detected_encoding = cchardet.detect(msg)
# eq_(
# "iso8859-2",
# detected_encoding['encoding'].lower(),
# assert "iso8859-2" == detected_encoding['encoding'].lower(), \
# 'Expected %s, but got %s' % (
# "iso8859-2",
# detected_encoding['encoding'].lower()
# )
# )