def test_get_argn(self): result = eval_repo.get_argn( os.path.join(os.path.dirname(__file__), 'from_sys_argv_example_00.py')) expected = 2 self.assertEqual(expected, result)
def test_get_argn_from_sys_import_argv_no_inline_comment(self): argv_file = tempf.write_to_temp_file("# comment a\n" "# comment b\n" "# commnet c\n" "\n" "from sys import argv\n" "\n" "a, b, c = argv\n" "\n" "print('a =', a)\n" "print('b =', b)\n" "print('c =', c)\n" "\n") result = eval_repo.get_argn(argv_file.name) os.remove(argv_file.name) expected = 3 self.assertEqual(expected, result)
def test_get_argn_from_sys_import_argv_with_equal_in_inline_comment(self): argv_file = tempf.write_to_temp_file( "# comment a\n" "# comment b\n" "# commnet c\n" "\n" "from sys import argv\n" "\n" "스크립트, 파일_이름 = argv #argv = 실행할때 사용자에게 입력 받음, 파일 이름은 경로까지!\n" "\n" "print('a =', a)\n" "print('b =', b)\n" "print('c =', c)\n" "\n") result = eval_repo.get_argn(argv_file.name) os.remove(argv_file.name) expected = 2 self.assertEqual(expected, result)
def test_get_argn_import_sys_with_inline_comment_trailing_comma(self): argv_file = tempf.write_to_temp_file( "# comment a\n" "# comment b\n" "# commnet c\n" "\n" "import sys\n" "\n" "a, b, c, = sys.argv # inline comment\n" "\n" "print('a =', a)\n" "print('b =', b)\n" "print('c =', c)\n" "\n") result = eval_repo.get_argn(argv_file.name) os.remove(argv_file.name) expected = 3 self.assertEqual(expected, result)
def test_get_argn_import_sys_comment(self): argv_file = tempf.write_to_temp_file("# comment a\n" "# comment b\n" "# commnet c\n" "\n" "import sys\n" "\n" "# a, b, c = sys.argv # comment\n" "a, b, c = 1, 2, 3 # comment\n" "\n" "print('a =', a)\n" "print('b =', b)\n" "print('c =', c)\n" "\n") result = eval_repo.get_argn(argv_file.name) os.remove(argv_file.name) expected = 0 self.assertEqual(expected, result)