misleading/cryptic exception message when invoking testr run with logically wrong arguments

Bug #1223941 reported by Peter Zsoldos on 2013-09-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Testrepository
High
Unassigned

Bug Description

I ran into this problem while running my first try of testrepository due to a mixup of how I usually run tests with unittest and what the default config suggests (http://testrepository.readthedocs.org/en/latest/MANUAL.html#python) - when I pass in the module name, as I would for -m unittest, it is ignored (after thinking, that's logical - the sample config does hardcode '.' for the start path from discover), and the cryptic error message is: "'unicodeescape' codec can't decode bytes in position 56-57: truncated \uXXXX escape"

I couldn't figure out how to get a traceback for the exception, so below are the relevant commands and their output for reproducing it (I included platform/version info too, though I expect the error effects all versions/platforms) in an empty (testr init) repo

My suggestion would be to turn it into a testr-specific error message, such as "incorrect options passed to run - no tests matching name <whatever passed in>"

=======

$ win_info
OS Name: Microsoft Windows 7 Professional
OS Manufacturer: Microsoft Corporation
System Type: x64-based PC
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
$ python --version
Python 2.7.4
$ pip freeze
extras==0.0.3
fixtures==0.3.14
python-mimeparse==0.1.4
python-subunit==0.0.15
testrepository==0.0.17
testtools==0.9.32
$ git --version
git version 1.8.1.msysgit.1
$ grep ^ -nH bugrepro/test.py bugrepro/__init__.py
bugrepro/test.py:1:import unittest
bugrepro/test.py:2:
bugrepro/test.py:3:
bugrepro/test.py:4:class SampleTest(unittest.TestCase):
bugrepro/test.py:5:
bugrepro/test.py:6: def test_one(self):
bugrepro/test.py:7: self.fail('one')
bugrepro/test.py:8:
bugrepro/test.py:9: def test_two(self):
bugrepro/test.py:10: pass
$ python -m unittest discover bugrepro
F.
======================================================================
FAIL: test_one (test.SampleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\zsoldosp_2\Documents\testint\bugrepro\test.py", line 7, in test_one
    self.fail('one')
AssertionError: one

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (failures=1)
$ ls .testr.conf .testr.conf.swp .testr.conf~ .testrepository -l
-rw-r--r-- 1 zsoldosp Administ 205 Sep 11 14:46 .testr.conf
-rw-r--r-- 1 zsoldosp Administ 12288 Sep 11 14:44 .testr.conf.swp
-rw-r--r-- 1 zsoldosp Administ 212 Sep 11 14:45 .testr.conf~

.testrepository:
total 1
-rw-r--r-- 1 zsoldosp Administ 3 Sep 11 16:28 format
-rw-r--r-- 1 zsoldosp Administ 3 Sep 11 16:28 next-stream
$ cat .testr.conf
[DEFAULT]
#test_command=python -m subunit.run discover . $LISTOPT $IDOPTION
test_command=python -m subunit.run discover . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
$ testr run bugrepro
running=python -m subunit.run discover . --list
'unicodeescape' codec can't decode bytes in position 56-57: truncated \uXXXX escape
$ testr run
running=python -m subunit.run discover .
======================================================================
FAIL: bugrepro.test.SampleTest.test_one
tags: worker-0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\zsoldosp_2\Documents\testint\bugrepro\test.py", line 7, in test_one
    self.fail('one')
  File "c:\Python27\Lib\unittest\case.py", line 413, in fail
    raise self.failureException(msg)
AssertionError: one
======================================================================
FAIL: process-returncode
tags: worker-0
----------------------------------------------------------------------
Binary content:
  traceback (test/plain; charset="utf8")
Ran 5 tests in 0.019s
FAILED (id=0, failures=2)

Robert Collins (lifeless) wrote :

Sorry, I'm not clear whats going wrong. It looks like you have a script to demonstrate it - could you please attach that to the bug, which will let me see it without the webformatting corrupting it.

Changed in testrepository:
status: New → Incomplete
importance: Undecided → High
Peter Zsoldos (zsoldosp) wrote :

Sorry about the late response, I seem to have misfiled this email. I've blogged the shell script I used at http://blog.zsoldosp.eu/2013/09/11/quick-script-to-help-reporting-bugs-for-python/

I'm pasting it here for convenience. It is designed to run on windows from the git-bash shell.

#!/bin/sh
function d() {
    echo "\$ $*"
    $*
}

function win_info() {
    systeminfo | grep "\(OS Name\|OS Manufacturer\|System Type\|Locale\)"
}

REPRO_FOLDER=bugrepro
d win_info
d python --version
d pip freeze
d git --version
d grep ^ -nH `find $REPRO_FOLDER -name \*.py`
d python -m unittest discover $REPRO_FOLDER
d ls .testr* -l
d cat .testr.conf
d testr run $REPRO_FOLDER
d testr run

HTH,

Peter

Robert Collins (lifeless) wrote :

Hi Peter - no worriees. So, TESTR_PDB=1 will trigger a pdb shell when testr itself fails - could you try that?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers