aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/scripts/err_return1
-rw-r--r--test/test_dump.py29
-rw-r--r--test/test_flow.py8
3 files changed, 26 insertions, 12 deletions
diff --git a/test/scripts/err_return b/test/scripts/err_return
index a45926b5..09e9eb5e 100755
--- a/test/scripts/err_return
+++ b/test/scripts/err_return
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import sys
sys.path.insert(0, "..")
+print >> sys.stderr, "output"
sys.exit(1)
diff --git a/test/test_dump.py b/test/test_dump.py
index 7b223645..46dd6dfd 100644
--- a/test/test_dump.py
+++ b/test/test_dump.py
@@ -6,19 +6,21 @@ import utils
class uDumpMaster(libpry.AutoTree):
- def _cycle(self, m):
+ def _cycle(self, m, content):
req = utils.treq()
+ req.content = content
cc = req.client_conn
resp = utils.tresp(req)
+ resp.content = content
m.handle_clientconnect(cc)
m.handle_request(req)
m.handle_response(resp)
- def _dummy_cycle(self, filt, **options):
+ def _dummy_cycle(self, filt, content, **options):
cs = StringIO()
o = dump.Options(**options)
m = dump.DumpMaster(None, o, filt, outfile=cs)
- self._cycle(m)
+ self._cycle(m, content)
return cs.getvalue()
def test_options(self):
@@ -27,16 +29,18 @@ class uDumpMaster(libpry.AutoTree):
libpry.raises(AttributeError, dump.Options, nonexistent = 2)
def test_filter(self):
- assert not "GET" in self._dummy_cycle("~u foo", verbosity=1)
+ assert not "GET" in self._dummy_cycle("~u foo", "", verbosity=1)
def test_basic(self):
for i in (1, 2, 3):
- assert "GET" in self._dummy_cycle("~s", verbosity=i)
+ assert "GET" in self._dummy_cycle("~s", "", verbosity=i)
+ assert "GET" in self._dummy_cycle("~s", "\x00\x00\x00", verbosity=i)
+ assert "GET" in self._dummy_cycle("~s", "ascii", verbosity=i)
def test_write(self):
d = self.tmpdir()
p = os.path.join(d, "a")
- self._dummy_cycle(None, wfile=p, verbosity=0)
+ self._dummy_cycle(None, "", wfile=p, verbosity=0)
assert len(list(flow.FlowReader(open(p)).stream())) == 1
def test_write_err(self):
@@ -44,33 +48,34 @@ class uDumpMaster(libpry.AutoTree):
dump.DumpError,
self._dummy_cycle,
None,
+ "",
wfile = "nonexistentdir/foo"
)
def test_request_script(self):
- ret = self._dummy_cycle(None, request_script="scripts/a", verbosity=1)
+ ret = self._dummy_cycle(None, "", request_script="scripts/a", verbosity=1)
assert "TESTOK" in ret
assert "DEBUG" in ret
libpry.raises(
dump.DumpError,
- self._dummy_cycle, None, request_script="nonexistent"
+ self._dummy_cycle, None, "", request_script="nonexistent"
)
libpry.raises(
dump.DumpError,
- self._dummy_cycle, None, request_script="scripts/err_data"
+ self._dummy_cycle, None, "", request_script="scripts/err_return"
)
def test_response_script(self):
- ret = self._dummy_cycle(None, response_script="scripts/a", verbosity=1)
+ ret = self._dummy_cycle(None, "", response_script="scripts/a", verbosity=1)
assert "TESTOK" in ret
assert "DEBUG" in ret
libpry.raises(
dump.DumpError,
- self._dummy_cycle, None, response_script="nonexistent"
+ self._dummy_cycle, None, "", response_script="nonexistent"
)
libpry.raises(
dump.DumpError,
- self._dummy_cycle, None, response_script="scripts/err_data"
+ self._dummy_cycle, None, "", response_script="scripts/err_return"
)
diff --git a/test/test_flow.py b/test/test_flow.py
index eb6a7c8c..168b4e74 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -51,6 +51,14 @@ class uFlow(libpry.AutoTree):
state = f.get_state()
assert f == flow.Flow.from_state(state)
+ f2 = utils.tflow()
+ f2.error = proxy.Error(f, "e2")
+ assert not f == f2
+ f.load_state(f2.get_state())
+ assert f == f2
+
+
+
def test_kill(self):
f = utils.tflow()
f.request = utils.treq()