[py-svn] commit/pytest: RonnyPfannschmidt: use os.path.expanduser/expandvars on the junitxml path for convience, fixes #44

Bitbucket commits-noreply at bitbucket.org
Fri May 27 08:00:29 CEST 2011


1 new changeset in pytest:

http://bitbucket.org/hpk42/pytest/changeset/8436bf14aae1/
changeset:   8436bf14aae1
branches:    
user:        RonnyPfannschmidt
date:        2011-05-27 07:54:03
summary:     use os.path.expanduser/expandvars on the junitxml path for convience, fixes #44
affected #:  2 files (477 bytes)

--- a/_pytest/junitxml.py	Fri May 13 09:57:35 2011 +0200
+++ b/_pytest/junitxml.py	Fri May 27 07:54:03 2011 +0200
@@ -65,7 +65,7 @@
 
 class LogXML(object):
     def __init__(self, logfile, prefix):
-        self.logfile = logfile
+        self.logfile = os.path.expanduser(os.path.expandvars(logfile))
         self.prefix = prefix
         self.test_logs = []
         self.passed = self.skipped = 0


--- a/testing/test_junitxml.py	Fri May 13 09:57:35 2011 +0200
+++ b/testing/test_junitxml.py	Fri May 27 07:54:03 2011 +0200
@@ -1,6 +1,6 @@
 
 from xml.dom import minidom
-import py, sys
+import py, sys, os
 
 def runandparse(testdir, *args):
     resultpath = testdir.tmpdir.join("junit.xml")
@@ -351,3 +351,16 @@
             assert '#x%04X' % i in text
     for i in valid:
         assert chr(i) in text
+
+def test_logxml_path_expansion():
+    from _pytest.junitxml import LogXML
+
+    home_tilde = py.path.local(os.path.expanduser('~/test.xml'))
+    # this is here for when $HOME is not set correct
+    home_var = py.path.local(os.path.expandvars('$HOME/test.xml'))
+
+    xml_tilde = LogXML('~/test.xml', None)
+    assert xml_tilde.logfile == home_tilde
+
+    xml_var = LogXML('$HOME/test.xml', None)
+    assert xml_var.logfile == home_var

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list