From 15c36ee9b39624a29303b6e0cf434c9758657ded Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 15 Jul 2011 17:20:27 -0400 Subject: If we're going to need indra.base.llsd, have to munge sys.path. And at that point, the Python logic needed to bring in the llsd module is big enough to warrant capturing it in a separate string variable common to multiple tests. --- indra/llcommon/tests/llsdserialize_test.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index 30cc2bbc8a..a54d861680 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -1673,9 +1673,21 @@ namespace tut struct TestPythonCompatible { - TestPythonCompatible() {} + TestPythonCompatible(): + import_llsd("import os.path\n" + "import sys\n" + "sys.path.insert(0,\n" + " os.path.join(os.path.dirname(__file__),\n" + " os.pardir, os.pardir, 'lib', 'python'))\n" + "try:\n" + " from llbase import llsd\n" + "except ImportError:\n" + " from indra.base import llsd\n") + {} ~TestPythonCompatible() {} + std::string import_llsd; + template void python(const std::string& desc, const CONTENT& script, int expect=0) { @@ -1802,10 +1814,7 @@ namespace tut python("read C++ notation", lambda::_1 << - "try:\n" - " from llbase import llsd\n" - "except ImportError:\n" - " from indra.base import llsd\n" + import_llsd << "def parse_each(iterable):\n" " for item in iterable:\n" " yield llsd.parse(item)\n" << @@ -1825,11 +1834,8 @@ namespace tut python("write Python notation", lambda::_1 << - "from __future__ import with_statement\n" - "try:\n" - " from llbase import llsd\n" - "except ImportError:\n" - " from indra.base import llsd\n" + "from __future__ import with_statement\n" << + import_llsd << "DATA = [\n" " 17,\n" " 3.14,\n" -- cgit v1.2.3