def test_generateTestScript(self): """ Test for L{generateTestScript} """ fname = self._outputToTempFile( dedent( ''' // import ConsoleJSTestFoo.Bar // import ConsoleJSTestFoo.Baz print("hello from the test module"); ''')) deps = getDependencies( fname, ignore=(), bootstrap=(), packages=self._getPackages()) script = generateTestScript( fname, dependencies=deps) scriptfname = self._outputToTempFile(script) def gotResult(s): self.assertEqual(s.split('\n'), ['hello from ConsoleJSTestFoo', 'hello from ConsoleJSTestFoo.Bar', 'hello from ConsoleJSTestFoo.Baz', 'hello from the test module', '']) result = getProcessOutput(self.javascriptInterpreter, ('-f', scriptfname)) result.addCallback(gotResult) return result
def test_generateTestScript(self): """ Test for L{generateTestScript} """ fname = self._outputToTempFile( dedent(''' // import ConsoleJSTestFoo.Bar // import ConsoleJSTestFoo.Baz print("hello from the test module"); ''')) deps = getDependencies(fname, ignore=(), bootstrap=(), packages=self._getPackages()) script = generateTestScript(fname, dependencies=deps) scriptfname = self._outputToTempFile(script) def gotResult(s): self.assertEqual(s.split('\n'), [ 'hello from ConsoleJSTestFoo', 'hello from ConsoleJSTestFoo.Bar', 'hello from ConsoleJSTestFoo.Baz', 'hello from the test module', '' ]) result = getProcessOutput(self.javascriptInterpreter, ('-f', scriptfname)) result.addCallback(gotResult) return result
def test_getDependenciesNoModules(self): """ Test that L{getDependencies} returns the empty list when the js module it's passed doesn't explicitly import anything and the C{bootstrap} and C{ignore} parameters are empty """ deps = getDependencies( self._outputToTempFile(''), ignore=(), bootstrap=()) self.assertEqual(len(deps), 0)
def test_getDependenciesNoModules(self): """ Test that L{getDependencies} returns the empty list when the js module it's passed doesn't explicitly import anything and the C{bootstrap} and C{ignore} parameters are empty """ deps = getDependencies(self._outputToTempFile(''), ignore=(), bootstrap=()) self.assertEqual(len(deps), 0)
def test_getDependenciesBootstrap(self): """ Test that L{getDependencies} returns a list containing only the bootstrap modules when the js module it's passed doesn't explicitly import anything and the "ignore" parameter is empty. """ bootstrap = ['ConsoleJSTestFoo.Bar', 'ConsoleJSTestFoo.Baz'] deps = getDependencies(self._outputToTempFile(''), ignore=(), bootstrap=bootstrap, packages=self._getPackages()) self.assertEqual([d.name for d in deps], bootstrap)
def test_getDependenciesBootstrap(self): """ Test that L{getDependencies} returns a list containing only the bootstrap modules when the js module it's passed doesn't explicitly import anything and the "ignore" parameter is empty. """ bootstrap = ['ConsoleJSTestFoo.Bar', 'ConsoleJSTestFoo.Baz'] deps = getDependencies( self._outputToTempFile(''), ignore=(), bootstrap=bootstrap, packages=self._getPackages()) self.assertEqual([d.name for d in deps], bootstrap)
def test_getDependenciesIgnore(self): """ Test that L{getDependencies} observes the C{ignore} parameter """ deps = getDependencies(self._outputToTempFile( dedent(''' // import ConsoleJSTestFoo.Bar // import ConsoleJSTestFoo.Baz ''')), ignore=('ConsoleJSTestFoo.Bar', ), bootstrap=(), packages=self._getPackages()) self.assertEqual([d.name for d in deps], ['ConsoleJSTestFoo', 'ConsoleJSTestFoo.Baz'])
def test_getDependenciesAll(self): """ Test that L{getDependencies} works if we import a single module which in turn depends on multiple modules """ fname = self._outputToTempFile('// import ConsoleJSTestFoo.Baz') deps = getDependencies(fname, ignore=(), bootstrap=(), packages=self._getPackages()) self.assertEqual([d.name for d in deps], [ 'ConsoleJSTestFoo', 'ConsoleJSTestFoo.Bar', 'ConsoleJSTestFoo.Baz' ])
def test_getDependenciesAll(self): """ Test that L{getDependencies} works if we import a single module which in turn depends on multiple modules """ fname = self._outputToTempFile( '// import ConsoleJSTestFoo.Baz') deps = getDependencies( fname, ignore=(), bootstrap=(), packages=self._getPackages()) self.assertEqual([d.name for d in deps], ['ConsoleJSTestFoo', 'ConsoleJSTestFoo.Bar', 'ConsoleJSTestFoo.Baz'])
def test_getDependenciesIgnore(self): """ Test that L{getDependencies} observes the C{ignore} parameter """ deps = getDependencies( self._outputToTempFile( dedent( ''' // import ConsoleJSTestFoo.Bar // import ConsoleJSTestFoo.Baz ''')), ignore=('ConsoleJSTestFoo.Bar',), bootstrap=(), packages=self._getPackages()) self.assertEqual([d.name for d in deps], ['ConsoleJSTestFoo', 'ConsoleJSTestFoo.Baz'])