Use current environment and executable in process

The GRAMPSHOME environment variable is not unset after the
gen/utils/test/file_test unit test.  This caused the Gramps
process to fail with an environment error.
This commit is contained in:
Nick Hall 2017-02-23 18:43:20 +00:00
parent d71f7d7097
commit a8e6f7b9a3
2 changed files with 15 additions and 8 deletions

View File

@ -24,6 +24,7 @@ Unittest for export to VCard
import unittest
import time
import subprocess
import sys
import os
import xml.etree.ElementTree as ET
@ -70,12 +71,14 @@ class VCardCheck(unittest.TestCase):
if debug:
print(ET.tostring(input_doc))
process = subprocess.Popen('python Gramps.py '
'-i - -f gramps -e - -f vcf',
pyexec = sys.executable
gcmd = 'Gramps.py -i - -f gramps -e - -f vcf'
process = subprocess.Popen('%s %s' % (pyexec, gcmd),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
shell=True,
env=os.environ)
input_str = (self.header.encode('utf-8') +
ET.tostring(input_doc, encoding='utf-8'))
result_str, err_str = process.communicate(input_str)

View File

@ -25,6 +25,8 @@ Unittest of import of VCard
# in case of a failing test, add True as last parameter to do_case to see the output.
import unittest
import sys
import os
import time
import subprocess
import xml.etree.ElementTree as ET
@ -75,14 +77,16 @@ class VCardCheck(unittest.TestCase):
def do_case(self, input_str, expect_doc, debug=False):
if debug:
print(input_str)
process = subprocess.Popen('python3 Gramps.py -d .Date -d .ImportVCard '
'--config=preferences.eprefix:DEFAULT '
'-i - -f vcf -e - -f gramps',
pyexec = sys.executable
gcmd = ('Gramps.py -d .Date -d .ImportVCard '
'--config=preferences.eprefix:DEFAULT '
'-i - -f vcf -e - -f gramps')
process = subprocess.Popen('%s %s' % (pyexec, gcmd),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
shell=True,
env=os.environ)
result_str, err_str = process.communicate(input_str.encode("utf-8"))
if debug:
print(err_str)