mirror of https://github.com/tc39/test262.git
load monkeyYaml without assuming it is on path
use imp to import monkeyYaml locally make monkeyYaml the backup again
This commit is contained in:
parent
e2b675f443
commit
9dc29da897
|
@ -16,6 +16,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import imp
|
||||||
|
|
||||||
# from TestCasePackagerConfig import *
|
# from TestCasePackagerConfig import *
|
||||||
|
|
||||||
|
@ -115,6 +116,19 @@ def importYamlLoad():
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
yamlLoad = yaml.load
|
yamlLoad = yaml.load
|
||||||
except ImportError:
|
except:
|
||||||
import monkeyYaml
|
monkeyYaml = loadMonkeyYaml()
|
||||||
yamlLoad = monkeyYaml.load
|
yamlLoad = monkeyYaml.load
|
||||||
|
|
||||||
|
def loadMonkeyYaml():
|
||||||
|
f = None
|
||||||
|
try:
|
||||||
|
p = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
(f, pathname, description) = imp.find_module("monkeyYaml", [p])
|
||||||
|
module = imp.load_module("monkeyYaml", f, pathname, description)
|
||||||
|
return module
|
||||||
|
except:
|
||||||
|
raise ImportError("Cannot load monkeyYaml")
|
||||||
|
finally:
|
||||||
|
if f:
|
||||||
|
f.close()
|
||||||
|
|
|
@ -7,12 +7,24 @@ import unittest
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
import imp
|
||||||
|
|
||||||
# add parent dir to search path
|
# add parent dir to search path
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, "..")
|
#sys.path.insert(0, "..")
|
||||||
|
|
||||||
import monkeyYaml
|
f = None
|
||||||
|
try:
|
||||||
|
(f, pathname, description) = imp.find_module("monkeyYaml", [os.path.join(os.getcwd(), "../")])
|
||||||
|
module = imp.load_module("monkeyYaml", f, pathname, description)
|
||||||
|
monkeyYaml = module
|
||||||
|
except:
|
||||||
|
raise ImportError("Cannot load monkeyYaml")
|
||||||
|
finally:
|
||||||
|
if f:
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
#import monkeyYaml
|
||||||
|
|
||||||
class TestMonkeyYAMLParsing(unittest.TestCase):
|
class TestMonkeyYAMLParsing(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue