CodyKochmann / battle_tested

Fully automated python fuzzer built to test if code actually is production ready in seconds.
MIT License
105 stars 5 forks source link

AttributeError during example from README #49

Open Skeen opened 3 years ago

Skeen commented 3 years ago

Steps to reproduce:

  1. Create a new virtual environment

    $ python3 -m venv ./venv
  2. Activate the virtual environment

    $ source venv/bin/activate
  3. Install battle_tested

    (venv)$ pip3 install battle_tested
  4. Run the example in python3:

    Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from battle_tested import fuzz
    >>> def test(a):
    ...     return int(a)
    ... 
    >>> fuzz(test)

Expected output:

Output similar to the README file.

Actual output:

testing: test()
tests: 28878     speed:   3788/sec  avg:  4802/sec in 6s    
compiling results...
fuzzing test() found:                                                          
+------------------------+---------+
|   crash_input_types    |    12   |
|    exception_types     |    3    |
|    iffy_input_types    |    3    |
|      output_types      |    1    |
| successful_input_types |    4    |
|     successful_io      |   512   |
|     unique_crashes     |    3    |
+------------------------+---------+
Traceback (most recent call last):
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/stricttuple/__init__.py", line 76, in _format_value
    return self._unicode(value)
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 238, in __getattr__
    raise AttributeError(name)
AttributeError: _unicode

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/battle_tested/__init__.py", line 1178, in __repr__
    return '\n'.join(table.get_string().splitlines()[2:])
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 1299, in get_string
    formatted_rows = self._format_rows(rows, options)
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 1249, in _format_rows
    return [self._format_row(row, options) for row in rows]
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 1249, in <listcomp>
    return [self._format_row(row, options) for row in rows]
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 1243, in _format_row
    return [
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 1244, in <listcomp>
    self._format_value(field, value)
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/stricttuple/__init__.py", line 78, in _format_value
    return self._unicode(value)
  File "/home/emil/projects/battle/venv/lib/python3.8/site-packages/prettytable/prettytable.py", line 238, in __getattr__
    raise AttributeError(name)
AttributeError: _unicode
Skeen commented 3 years ago

It can be fixed by changing self._unicode( to str( in stricttuple/__init__.py's _format_value function.