예제 #1
0
파일: test.py 프로젝트: ralphbean/pbs
    def test_multiple_args_long_option(self):
        from pbs import python

        py = create_tmp_test("""
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-l", "--long-option", dest="long_option")
options, args = parser.parse_args()
print len(options.long_option.split())
""")
        num_args = int(python(py.name, long_option="one two three"))
        self.assertEqual(num_args, 3)

        num_args = int(python(py.name, "--long-option", "one's two's three's"))
        self.assertEqual(num_args, 3)
예제 #2
0
파일: test.py 프로젝트: dbarnett/pbs
    def test_multiple_args_long_option(self):
        from pbs import python
        
        py = create_tmp_test("""
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-l", "--long-option", dest="long_option")
options, args = parser.parse_args()
print len(options.long_option.split())
""")
        num_args = int(python(py.name, long_option="one two three"))
        self.assertEqual(num_args, 3)
        
        num_args = int(python(py.name, "--long-option", "one's two's three's"))
        self.assertEqual(num_args, 3)
예제 #3
0
파일: test.py 프로젝트: fruch/pbs
    def test_environment(self):
        from pbs import python
        import os
        
        env = {"HERP": "DERP"}
        
        py = create_tmp_test("""
import os
print os.environ["HERP"], len(os.environ)
""")
        out = python(py.name, _env=env).strip()
        self.assertEqual(out, "DERP 1")
    
        py = create_tmp_test("""
import pbs, os
print pbs.HERP, len(os.environ)
""")
        out = python(py.name, _env=env).strip()
        self.assertEqual(out, "DERP 1")
예제 #4
0
파일: test.py 프로젝트: ralphbean/pbs
    def test_environment(self):
        from pbs import python
        import os

        env = {"HERP": "DERP"}

        py = create_tmp_test("""
import os
print os.environ["HERP"], len(os.environ)
""")
        out = python(py.name, _env=env).strip()
        self.assertEqual(out, "DERP 1")

        py = create_tmp_test("""
import pbs, os
print pbs.HERP, len(os.environ)
""")
        out = python(py.name, _env=env).strip()
        self.assertEqual(out, "DERP 1")
예제 #5
0
파일: test.py 프로젝트: dbarnett/pbs
    def test_environment(self):
        from pbs import python
        import os
        
        env_value = "DERP"
        
        py = create_tmp_test("""
import os
print os.environ["HERP"]
""")
        os.environ["HERP"] = env_value
        out = python(py.name).strip()
        self.assertEqual(out, env_value)
    
        py = create_tmp_test("""
import pbs
print pbs.HERP
""")
        out = python(py.name).strip()
        self.assertEqual(out, env_value)
예제 #6
0
파일: test.py 프로젝트: dbarnett/pbs
    def test_number_arg(self):
        from pbs import python
        
        py = create_tmp_test("""
from optparse import OptionParser
parser = OptionParser()
options, args = parser.parse_args()
print args[0]
""")
        
        out = python(py.name, 3).strip()
        self.assertEqual(out, "3")
예제 #7
0
파일: test.py 프로젝트: ralphbean/pbs
    def test_number_arg(self):
        from pbs import python

        py = create_tmp_test("""
from optparse import OptionParser
parser = OptionParser()
options, args = parser.parse_args()
print args[0]
""")

        out = python(py.name, 3).strip()
        self.assertEqual(out, "3")
예제 #8
0
파일: test.py 프로젝트: dbarnett/pbs
    def test_quote_escaping(self):
        from pbs import python
        
        py = create_tmp_test("""
from optparse import OptionParser
parser = OptionParser()
options, args = parser.parse_args()
print args
""")
        out = python(py.name, "one two three").strip()
        self.assertEqual(out, "['one two three']")
        
        out = python(py.name, "one \"two three").strip()
        self.assertEqual(out, "['one \"two three']")
        
        out = python(py.name, "one", "two three").strip()
        self.assertEqual(out, "['one', 'two three']")
        
        out = python(py.name, "one", "two \"haha\" three").strip()
        self.assertEqual(out, "['one', 'two \"haha\" three']")
        
        out = python(py.name, "one two's three").strip()
        self.assertEqual(out, "[\"one two's three\"]")
        
        out = python(py.name, 'one two\'s three').strip()
        self.assertEqual(out, "[\"one two's three\"]")
예제 #9
0
파일: test.py 프로젝트: ralphbean/pbs
    def test_quote_escaping(self):
        from pbs import python

        py = create_tmp_test("""
from optparse import OptionParser
parser = OptionParser()
options, args = parser.parse_args()
print args
""")
        out = python(py.name, "one two three").strip()
        self.assertEqual(out, "['one two three']")

        out = python(py.name, "one \"two three").strip()
        self.assertEqual(out, "['one \"two three']")

        out = python(py.name, "one", "two three").strip()
        self.assertEqual(out, "['one', 'two three']")

        out = python(py.name, "one", "two \"haha\" three").strip()
        self.assertEqual(out, "['one', 'two \"haha\" three']")

        out = python(py.name, "one two's three").strip()
        self.assertEqual(out, "[\"one two's three\"]")

        out = python(py.name, 'one two\'s three').strip()
        self.assertEqual(out, "[\"one two's three\"]")
예제 #10
0
파일: test.py 프로젝트: jacebrowning/pbs
    def test_err_to_out2(self):
        from pbs import python
        out = python('-c','import sys; sys.stderr.write("omg")', _err_to_out=True)

        self.assertTrue("omg" in out)