summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jq.pyx6
-rw-r--r--tests/jq_tests.py6
2 files changed, 11 insertions, 1 deletions
diff --git a/jq.pyx b/jq.pyx
index 6d26470..cad78e5 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -131,8 +131,12 @@ cdef class _Program(object):
program_with_input._bytes_input = string_input.encode("utf8")
return program_with_input
+ @property
+ def program_string(self):
+ return self._program_bytes.decode("utf8")
+
def __repr__(self):
- return "jq.compile({!r})".format(self._program_bytes.decode("utf8"))
+ return "jq.compile({!r})".format(self.program_string)
cdef class _ProgramWithInput(object):
diff --git a/tests/jq_tests.py b/tests/jq_tests.py
index 7b82794..17dfc0c 100644
--- a/tests/jq_tests.py
+++ b/tests/jq_tests.py
@@ -189,3 +189,9 @@ def repr_of_compile_result_is_compilation_string():
program = jq.compile(".")
repr_string = repr(program)
assert_equal("jq.compile({!r})".format("."), repr_string)
+
+
+@istest
+def program_string_can_be_retrieved_from_program():
+ program = jq.compile(".")
+ assert_equal(".", program.program_string)