def _fixture(self, opts): self.conn = conn = config.db.connect() if opts.get("as_sql", False): self.context = MigrationContext.configure(dialect=conn.dialect, opts=opts) self.context.output_buffer = ( self.context.impl.output_buffer) = compat.StringIO() else: self.context = MigrationContext.configure(connection=conn, opts=opts) return self.context
def test_version_text(self): buf = compat.StringIO() to_mock = "sys.stdout" if util.compat.py3k else "sys.stderr" with mock.patch(to_mock, buf): try: config.CommandLine(prog="test_prog").main(argv=["--version"]) assert False except SystemExit: pass is_true("test_prog" in str(buf.getvalue())) is_true(__version__ in str(buf.getvalue()))
def _assert_impl_steps(self, *steps): to_check = self.context.output_buffer.getvalue() self.context.impl.output_buffer = buf = compat.StringIO() for step in steps: if step == "BEGIN": self.context.impl.emit_begin() elif step == "COMMIT": self.context.impl.emit_commit() else: self.context.impl._exec(step) eq_(to_check, buf.getvalue())