예제 #1
0
    def test_setup_egg_info(self):
        """
        Emulate the execution of ``python setup.py egg_info``.

        Ensure everything is covered.
        """

        # naturally, run it like we mean it.
        stdout, stderr = fork_exec(
            [sys.executable, 'setup.py', 'egg_info'],
            cwd=self.pkg_root,
        )
        self.assertIn('writing bower_json', stdout)
        self.assertIn('writing extras_calmjs', stdout)

        egg_root = join(self.pkg_root, 'dummy_pkg.egg-info')

        with open(join(egg_root, 'bower.json')) as fd:
            self.assertEqual(json.load(fd), {
                'dependencies': {
                    'jquery': '~3.0.0',
                },
            })

        with open(join(egg_root, 'extras_calmjs.json')) as fd:
            self.assertEqual(json.load(fd), {
                'bower_components': {
                    'jquery': 'jquery/dist/jquery.js',
                },
            })
예제 #2
0
 def test_fork_exec_bytes(self):
     stdout, stderr = fork_exec(
         [sys.executable, '-c', 'import sys;print(sys.stdin.read())'],
         stdin=b'hello',
         env=finalize_env({}),
     )
     self.assertEqual(stdout.strip(), b'hello')
예제 #3
0
파일: test_utils.py 프로젝트: calmjs/calmjs
 def test_fork_exec_str(self):
     stdout, stderr = fork_exec(
         [sys.executable, '-c', 'import sys;print(sys.stdin.read())'],
         stdin=u'hello',
         env=finalize_env({}),
     )
     self.assertEqual(stdout.strip(), u'hello')
예제 #4
0
파일: base.py 프로젝트: metatoaster/calmjs
    def _exec(self, binary, stdin='', args=(), env={}):
        """
        Executes the binary using stdin and args with environment
        variables.

        Returns a tuple of stdout, stderr.  Format determined by the
        input text (either str or bytes), and the encoding of str will
        be determined by the locale this module was imported in.
        """

        call_kw = self._gen_call_kws(**env)
        call_args = [self._get_exec_binary(call_kw)]
        call_args.extend(args)
        return fork_exec(call_args, stdin, **call_kw)