This repository was archived by the owner on Aug 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Expand file tree Collapse file tree 4 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 28
28
from . import fuzz
29
29
from . import utils
30
30
import heapq
31
- import warnings
31
+ import logging
32
32
33
- warnings .simplefilter ('always' )
34
33
35
34
default_scorer = fuzz .WRatio
35
+
36
+
36
37
default_processor = utils .full_process
37
38
38
39
@@ -101,7 +102,9 @@ def no_process(x):
101
102
processed_query = processor (query )
102
103
103
104
if len (processed_query ) == 0 :
104
- warnings .warn ("Applied processor reduces input query to empty string, all comparisons will have score 0." )
105
+ logging .warning ("Applied processor reduces input query to empty string, "
106
+ "all comparisons will have score 0. "
107
+ "[Query: \' {0}\' ]" .format (query ))
105
108
106
109
# If the scorer performs full_ratio with force ascii don't run full_process twice
107
110
if scorer in [fuzz .WRatio , fuzz .QRatio ,
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ def decorator(*args, **kwargs):
32
32
return func (* args , ** kwargs )
33
33
return decorator
34
34
35
+
35
36
bad_chars = str ("" ).join ([chr (i ) for i in range (128 , 256 )]) # ascii dammit!
36
37
if PY3 :
37
38
translation_table = dict ((ord (c ), None ) for c in bad_chars )
Original file line number Diff line number Diff line change @@ -511,7 +511,7 @@ def test_simplematch(self):
511
511
512
512
class TestCodeFormat (unittest .TestCase ):
513
513
def test_pep8_conformance (self ):
514
- pep8style = pycodestyle .StyleGuide (quiet = True )
514
+ pep8style = pycodestyle .StyleGuide (quiet = False )
515
515
pep8style .options .ignore = pep8style .options .ignore + tuple (['E501' ])
516
516
pep8style .input_dir ('fuzzywuzzy' )
517
517
result = pep8style .check_files ()
Original file line number Diff line number Diff line change 1
- import warnings
2
1
from fuzzywuzzy import process
3
2
4
3
5
- def test_process_warning ():
6
- """Check that a string reduced to 0 by processor raises a warning"""
4
+ def test_process_warning (capsys ):
5
+ """Check that a string reduced to 0 by processor logs a warning to stderr"""
6
+
7
7
query = ':::::::'
8
8
choices = [':::::::' ]
9
- with warnings .catch_warnings (record = True ) as w :
10
- result = process .extractOne (query , choices )
11
- assert issubclass (w [- 1 ].category , UserWarning )
12
- assert result == (query , 0 )
9
+
10
+ _ = process .extractOne (query , choices )
11
+
12
+ out , err = capsys .readouterr ()
13
+
14
+ outstr = ("WARNING:root:Applied processor reduces "
15
+ "input query to empty string, "
16
+ "all comparisons will have score 0. "
17
+ "[Query: ':::::::']\n " )
18
+
19
+ assert err == outstr
You can’t perform that action at this time.
0 commit comments