from cwf.splitter.imports import steal import os this_dir = os.path.dirname(__file__) steal('numbers', 'letters', folder=os.path.join(this_dir, 'vars'), globals=globals(), locals=locals()) __ignored = 'ignored' _hidden = '_hidden'
# coding: spec from cwf.splitter.imports import steal import stolen_vars import itertools import fudge describe "Stealing variables": it "should complain if folder, globals or locals isn't supplied": value = fudge.Fake("value") for combination in itertools.combinations(['folder', 'globals', 'locals'], 2): kwargs = {key:value for key in combination} with self.assertRaises(Exception): steal("a", **kwargs) @fudge.patch("__builtin__.execfile", "os.path.join") it "execfiles on combination of folder and each filename with globals and locals", fake_execfile, fake_join: fn1 = fudge.Fake("fn1") fn2 = fudge.Fake("fn2") folder = fudge.Fake("folder") location1 = fudge.Fake("location1") location2 = fudge.Fake("location2") lcls = fudge.Fake("lcls") glbls = fudge.Fake("glbls") # Each location execfile'd is determined by joining folder with each filename (fake_join.expects_call() .with_args(folder, "%s.py" % fn1).returns(location1)
from cwf.splitter.imports import steal import os this_dir = os.path.dirname(__file__) steal('numbers', 'letters' , folder=os.path.join(this_dir, 'vars'), globals=globals(), locals=locals() ) __ignored = 'ignored' _hidden = '_hidden'