def test_connection_error(self): """Connecting to an unknown domain should raise a ConnectionError""" with pytest.raises(ConnectionError): requests.get("http://fooobarbangbazbing.httpbin.org") with pytest.raises(ConnectionError): requests.get("http://httpbin.org:1")
def test_connect_and_disconnect_container(self): net_name, net_id = self.create_network() container = self.client.create_container('busybox', 'top') self.tmp_containers.append(container) self.client.start(container) network_data = self.client.inspect_network(net_id) self.assertFalse(network_data.get('Containers')) self.client.connect_container_to_network(container, net_id) network_data = self.client.inspect_network(net_id) self.assertEqual( list(network_data['Containers'].keys()), [container['Id']]) with pytest.raises(docker.errors.APIError): self.client.connect_container_to_network(container, net_id) self.client.disconnect_container_from_network(container, net_id) network_data = self.client.inspect_network(net_id) self.assertFalse(network_data.get('Containers')) with pytest.raises(docker.errors.APIError): self.client.disconnect_container_from_network(container, net_id)
def test_normal_function(self): i = [iter(range(100)) for x in range(3)] e = expandable_chain() e.extend(i) assert list(e) == list(range(100))*3 for x in i + [e]: pytest.raises(StopIteration, x.__next__)
def test_sample_weights_ne1(table): """Tests that a series of weights with total != 1 is not accepted""" with pytest.raises(ValueError): table.sample(table.num_rows, weights=[1/4, 1/4, 1/4, 1/6]) with pytest.raises(ValueError): table.sample(table.num_rows, weights=[1/4, 1/4, 1/4, 1/2])
def test_nested_scope(self): from pandas.core.computation.ops import UndefinedVariableError engine = self.engine parser = self.parser # smoke test x = 1 # noqa result = pd.eval('x + 1', engine=engine, parser=parser) assert result == 2 df = DataFrame(np.random.randn(5, 3)) df2 = DataFrame(np.random.randn(5, 3)) # don't have the pandas parser with pytest.raises(SyntaxError): df.query('(@df>0) & (@df2>0)', engine=engine, parser=parser) with pytest.raises(UndefinedVariableError): df.query('(df>0) & (df2>0)', engine=engine, parser=parser) expected = df[(df > 0) & (df2 > 0)] result = pd.eval('df[(df > 0) & (df2 > 0)]', engine=engine, parser=parser) assert_frame_equal(expected, result) expected = df[(df > 0) & (df2 > 0) & (df[df > 0] > 0)] result = pd.eval('df[(df > 0) & (df2 > 0) & (df[df > 0] > 0)]', engine=engine, parser=parser) assert_frame_equal(expected, result)
def test_pqueue_message_expiry(live_servicebus_config, partitioned_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) import uuid queue_client = client.get_queue(partitioned_queue) with queue_client.get_sender() as sender: content = str(uuid.uuid4()) message = Message(content) sender.send(message) with queue_client.get_receiver() as receiver: messages = receiver.fetch_next(timeout=10) assert len(messages) == 1 time.sleep(30) assert messages[0].expired with pytest.raises(MessageLockExpired): messages[0].complete() with pytest.raises(MessageLockExpired): messages[0].renew_lock() with queue_client.get_receiver() as receiver: messages = receiver.fetch_next(timeout=30) assert len(messages) == 1 print_message(messages[0]) assert messages[0].header.delivery_count > 0 messages[0].complete()
def test_with_column(table): column_1 = [10, 20, 30, 40] column_2 = 'hello' table2 = table.with_column('new_col1', column_1) table3 = table2.with_column('new_col2', column_2) assert_equal(table, """ letter | count | points a | 9 | 1 b | 3 | 2 c | 3 | 2 z | 1 | 10 """) assert_equal(table2, """ letter | count | points | new_col1 a | 9 | 1 | 10 b | 3 | 2 | 20 c | 3 | 2 | 30 z | 1 | 10 | 40 """) assert_equal(table3, """ letter | count | points | new_col1 | new_col2 a | 9 | 1 | 10 | hello b | 3 | 2 | 20 | hello c | 3 | 2 | 30 | hello z | 1 | 10 | 40 | hello """) with(pytest.raises(ValueError)): table.append_column('bad_col', [1, 2]) with(pytest.raises(ValueError)): table.append_column(0, [1, 2, 3, 4])
def test_cluster(some_clusters): """Test base functionality of :class:`~.db.Cluster`.""" # Test empty cluster attributes. cluster = Cluster() assert cluster.size == 0 assert cluster.size_urls == 0 assert cluster.frequency == 0 with pytest.raises(ValueError) as excinfo: cluster.span assert 'No urls' in str(excinfo.value) assert cluster.urls == [] # Test clusters from database. with session_scope() as session: assert session.query(Cluster).count() == 5 assert session.query(Cluster.sid).all() == \ [(i,) for i in some_clusters] assert session.query(Cluster).filter_by(sid=0).one().size == 0 assert session.query(Cluster).filter_by(sid=0).one().size_urls == 0 assert session.query(Cluster).filter_by(sid=0).one().frequency == 0 with pytest.raises(ValueError) as excinfo: session.query(Cluster).filter_by(sid=0).one().span assert 'No urls' in str(excinfo.value) assert session.query(Cluster).filter_by(sid=0).one().urls == [] assert session.query(Cluster).get(1).format_copy() == \ '1\t0\tFalse\ttest'
def test_reset_twice_error(self): with self.getcapture() as cap: print("hello") out, err = cap.readouterr() pytest.raises(ValueError, cap.stop_capturing) assert out == "hello\n" assert not err
def test_create_index_fails(self, sql): with pytest.raises(KeyError): create_index(sql, 'z', name='zidx') with pytest.raises(ValueError): create_index(sql, 'x') with pytest.raises(ValueError): create_index(sql, 'z')
def test_client_badconf(self): config = {'host': 'localhost'} pytest.raises(KeyError, AnalysisClient, config) config['port'] = TESTING_CONFIG['port'] conn = AnalysisClient(config) conn.host == TESTING_CONFIG['host'] conn.port == TESTING_CONFIG['port']
def test_element_coerce_from(fx_test_doc): doc, _ = fx_test_doc doc.title_attr = 'coerce test' assert isinstance(doc.title_attr, TextElement) assert doc.title_attr.value == 'coerce test' with raises(TypeError): doc.title_attr = 123 doc.multi_attr = [TextElement(value='a'), 'b'] for e in doc.multi_attr: assert isinstance(e, TextElement) assert doc.multi_attr[0].value == 'a' assert doc.multi_attr[1].value == 'b' with raises(TypeError): doc.multi_attr = [TextElement(value='a'), 'b', 3] number = len(doc.multi_attr) doc.multi_attr.append('coerce test') assert len(doc.multi_attr) == number + 1 for e in doc.multi_attr: assert isinstance(e, TextElement) assert doc.multi_attr[-1].value == 'coerce test' with raises(TypeError): doc.multi_attr.append(123) doc.multi_attr[0] = 'coerce test' assert isinstance(doc.multi_attr[0], TextElement) assert doc.multi_attr[0].value == 'coerce test' with raises(TypeError): doc.multi_attr[1] = 123 doc.multi_attr[1:] = ['slice', 'test'] for e in doc.multi_attr: assert isinstance(e, TextElement) assert doc.multi_attr[1].value == 'slice' assert doc.multi_attr[2].value == 'test' with raises(TypeError): doc.multi_attr[1:] = ['slice test', 123]
def test_strategy_attribute_replaced(self): sd = StrategyDict("sd") sd.strategy("add", "+", keep_name=True)(operator.add) sd.strategy("mul", "*", keep_name=True)(operator.mul) sd.strategy("sub", "-", keep_name=True)(operator.sub) # Replaces the strategy attribute, but keeps the strategy there sd.sub = 14 assert set(sd.keys()) == {("add", "+"), ("mul", "*"), ("sub", "-",)} assert sd["sub"](5, 4) == 1 assert sd.sub == 14 # Removes the strategy with replaced attribute, keeping the attribute del sd["sub"] # Removes the strategy assert sd.sub == 14 # Still there assert set(sd.keys()) == {("add", "+"), ("mul", "*"), ("-",)} # Removes the replaced attribute, keeping the strategy sd.add = None assert sd.add is None assert sd["add"](3, 7) == 10 del sd.add # Removes the attribute assert sd.add(4, 7) == 11 == sd["add"](4, 7) assert set(sd.keys()) == {("add", "+"), ("mul", "*"), ("-",)} # Removes the strategy whose attribute had been replaced del sd.add # Removes the strategy assert set(sd.keys()) == {("+",), ("mul", "*"), ("-",)} with pytest.raises(KeyError): sd["add"](5, 4) with pytest.raises(AttributeError): sd.add(5, 4)
def test_key2keys_value2keys(self): md = MultiKeyDict() md[1] = 7 md[2] = 7 md[3] = -4 md[4] = -4 md[-4] = 1 assert md.key2keys(1) == md.key2keys(2) == (1, 2) == md.value2keys(7) assert md.key2keys(3) == md.key2keys(4) == (3, 4) == md.value2keys(-4) assert md.key2keys(-4) == (-4,) == md.value2keys(1) assert len(md) == 3 del md[2] assert md.key2keys(1) == (1,) == md.value2keys(7) assert md.key2keys(3) == md.key2keys(4) == (3, 4) == md.value2keys(-4) assert md.key2keys(-4) == (-4,) == md.value2keys(1) assert len(md) == 3 with pytest.raises(KeyError): md.key2keys(2) del md[1] assert md.value2keys(7) == tuple() assert md.key2keys(3) == md.key2keys(4) == (3, 4) == md.value2keys(-4) assert md.key2keys(-4) == (-4,) == md.value2keys(1) assert len(md) == 2 with pytest.raises(KeyError): md.key2keys(1) with pytest.raises(KeyError): md.key2keys(2)
def test_pqueue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deletemode(live_servicebus_config, partitioned_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(partitioned_queue) deferred_messages = [] messages = [Message("Deferred message no. {}".format(i)) for i in range(10)] for m in messages: m.partition_key = "MyPartitionKey" results = queue_client.send(messages) assert all(result[0] for result in results) count = 0 receiver = queue_client.get_receiver(idle_timeout=5) for message in receiver: deferred_messages.append(message.sequence_number) print_message(message) count += 1 message.defer() assert count == 10 with queue_client.get_receiver(idle_timeout=5) as receiver: deferred = receiver.receive_deferred_messages(deferred_messages, mode=ReceiveSettleMode.ReceiveAndDelete) assert len(deferred) == 10 for message in deferred: assert isinstance(message, DeferredMessage) with pytest.raises(MessageAlreadySettled): message.complete() with pytest.raises(ServiceBusError): deferred = receiver.receive_deferred_messages(deferred_messages)
def test_vel_transformation_obstime_err(): # TODO: replace after a final decision on PR #6280 from astropy.coordinates.sites import get_builtin_sites diff = r.CartesianDifferential([.1, .2, .3]*u.km/u.s) rep = r.CartesianRepresentation([1, 2, 3]*u.au, differentials=diff) loc = get_builtin_sites()['example_site'] aaf = AltAz(obstime='J2010', location=loc) aaf2 = AltAz(obstime=aaf.obstime + 3*u.day, location=loc) aaf3 = AltAz(obstime=aaf.obstime + np.arange(3)*u.day, location=loc) aaf4 = AltAz(obstime=aaf.obstime, location=loc) aa = aaf.realize_frame(rep) with pytest.raises(NotImplementedError) as exc: aa.transform_to(aaf2) assert 'cannot transform' in exc.value.args[0] with pytest.raises(NotImplementedError) as exc: aa.transform_to(aaf3) assert 'cannot transform' in exc.value.args[0] aa.transform_to(aaf4) aa.transform_to(ICRS())
def test_pqueue_by_servicebus_client_iter_messages_with_retrieve_deferred_not_found(live_servicebus_config, partitioned_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(partitioned_queue) deferred_messages = [] with queue_client.get_receiver(idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver: with queue_client.get_sender() as sender: for i in range(3): message = Message("Deferred message no. {}".format(i)) message.partition_key = "MyPartitionKey" sender.send(message) count = 0 for message in receiver: deferred_messages.append(message.sequence_number) print_message(message) count += 1 message.defer() assert count == 3 with pytest.raises(ServiceBusError): deferred = queue_client.receive_deferred_messages([3, 4], mode=ReceiveSettleMode.PeekLock) with pytest.raises(ServiceBusError): deferred = queue_client.receive_deferred_messages([5, 6, 7], mode=ReceiveSettleMode.PeekLock)
def test_setitem_ndarray_1d(self): # GH5508 # len of indexer vs length of the 1d ndarray df = DataFrame(index=Index(lrange(1, 11))) df['foo'] = np.zeros(10, dtype=np.float64) df['bar'] = np.zeros(10, dtype=np.complex) # invalid def f(): df.loc[df.index[2:5], 'bar'] = np.array([2.33j, 1.23 + 0.1j, 2.2, 1.0]) pytest.raises(ValueError, f) # valid df.loc[df.index[2:6], 'bar'] = np.array([2.33j, 1.23 + 0.1j, 2.2, 1.0]) result = df.loc[df.index[2:6], 'bar'] expected = Series([2.33j, 1.23 + 0.1j, 2.2, 1.0], index=[3, 4, 5, 6], name='bar') tm.assert_series_equal(result, expected) # dtype getting changed? df = DataFrame(index=Index(lrange(1, 11))) df['foo'] = np.zeros(10, dtype=np.float64) df['bar'] = np.zeros(10, dtype=np.complex) def f(): df[2:5] = np.arange(1, 4) * 1j pytest.raises(ValueError, f)
def test_pqueue_message_receive_and_delete(live_servicebus_config, partitioned_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(partitioned_queue) with queue_client.get_sender() as sender: message = Message("Receive and delete test") sender.send(message) with queue_client.get_receiver(mode=ReceiveSettleMode.ReceiveAndDelete) as receiver: messages = receiver.fetch_next(timeout=10) assert len(messages) == 1 received = messages[0] print_message(received) with pytest.raises(MessageAlreadySettled): received.complete() with pytest.raises(MessageAlreadySettled): received.abandon() with pytest.raises(MessageAlreadySettled): received.defer() with pytest.raises(MessageAlreadySettled): received.dead_letter() with pytest.raises(MessageAlreadySettled): received.renew_lock() time.sleep(30) with queue_client.get_receiver() as receiver: messages = receiver.fetch_next(timeout=10) for m in messages: print_message(m) assert len(messages) == 0
def test_remove(registry, what2nick): what, whatid, nick = what2nick # remove by nickname assert what == registry.register(what, nick) assert registry.list() == [(nick, whatid)] registry.remove(nickname=nick) assert registry.list() == [] # remove by whatid assert what == registry.register(what, nick) assert registry.list() == [(nick, whatid)] registry.remove(what=what) assert registry.list() == [] # remove by both need to match the entry assert what == registry.register(what, nick) assert registry.list() == [(nick, whatid)] with pytest.raises(ValueError): registry.remove(what=what, nickname='NO') assert registry.list() == [(nick, whatid)] with pytest.raises(ValueError): registry.remove(what='NO()', nickname=nick) # remove does not accept None parameters with pytest.raises(ValueError) as excinfo: registry.remove() assert 'at least one of nickname or what must be provided' == str(excinfo.value)
def test_relabel(): table = Table([(1, 2, 3), (12345, 123, 5123)], ['points', 'id']) table.relabel('id', 'todo') assert_equal(table, """ points | todo 1 | 12345 2 | 123 3 | 5123 """) table.relabel(1, 'yolo') assert_equal(table, """ points | yolo 1 | 12345 2 | 123 3 | 5123 """) table.relabel(['points', 'yolo'], ['red', 'blue']) assert_equal(table, """ red | blue 1 | 12345 2 | 123 3 | 5123 """) with(pytest.raises(ValueError)): table.relabel(['red', 'blue'], ['magenta', 'cyan', 'yellow']) with(pytest.raises(ValueError)): table.relabel(['red', 'green'], ['magenta', 'yellow'])
def test_terminal_functions(terminal): terminal.flash() assert curses.flash.called terminal.getch() assert terminal.stdscr.getch.called with pytest.raises(RuntimeError): with terminal.no_delay(): raise RuntimeError() terminal.stdscr.nodelay.assert_any_call(0) terminal.stdscr.nodelay.assert_any_call(1) curses.endwin.reset_mock() curses.doupdate.reset_mock() with terminal.suspend(): pass assert curses.endwin.called assert curses.doupdate.called curses.endwin.reset_mock() curses.doupdate.reset_mock() with pytest.raises(RuntimeError): with terminal.suspend(): raise RuntimeError() assert curses.endwin.called assert curses.doupdate.called terminal.addch(terminal.stdscr, 3, 5, 'ch', 'attr') terminal.stdscr.addch.assert_called_with(3, 5, 'ch', 'attr')
def test_save_store_fs_change_pootle_path_or_store(en_tutorial_po_fs_store): """You cant change a pootle_path if a store is associated unless you also remove the store association - and vice versa """ fs_store = en_tutorial_po_fs_store store = fs_store.store other_path = "/en/tutorial/other.po" fs_store.pootle_path = other_path with pytest.raises(ValidationError): fs_store.save() fs_store.store = None fs_store.save() assert fs_store.store is None assert fs_store.pootle_path == other_path fs_store.store = store with pytest.raises(ValidationError): fs_store.save() fs_store.pootle_path = store.pootle_path fs_store.save() assert fs_store.store == store assert fs_store.pootle_path == store.pootle_path
def test_UnitConverter_nodistance(): mywcs = WCS(hdr) convert = UnitConverter(mywcs) assert convert.ang_size.value == np.abs(hdr['CDELT2']) assert convert.ang_size.unit == mywcs.wcs.cunit[0] twopix_ang = np.abs(hdr['CDELT2']) * 2 * u.deg assert convert.to_pixel(twopix_ang).value == 2. assert convert.to_pixel_area(twopix_ang**2) == 4 * u.pix**2 assert convert.from_pixel(2 * u.pix, u.deg) == twopix_ang assert convert.to_angular(2 * u.pix, u.deg) == twopix_ang # Round trip assert convert.to_pixel(convert.from_pixel(2 * u.pix, u.deg)) == 2 * u.pix assert convert.to_pixel(convert.to_angular(2 * u.pix, u.deg)) == 2 * u.pix assert convert.from_pixel(convert.to_pixel(twopix_ang), u.deg) == twopix_ang assert convert.to_angular(convert.to_pixel(twopix_ang), u.deg) == twopix_ang # Physical conversions should fail with pytest.raises(AttributeError): convert.from_pixel(2 * u.pix, u.pc) with pytest.raises(AttributeError): assert convert.to_physical(2 * u.pix, u.pc)
def test_getitem(self): c = caching_iter(range(20)) assert c[-1] == 19 with pytest.raises(IndexError): operator.getitem(c, -21) with pytest.raises(IndexError): operator.getitem(c, 21)
def test_fetch_file(url, tmpdir): """Test URL retrieval.""" tempdir = str(tmpdir) archive_name = op.join(tempdir, "download_test") with catch_logging() as log: _fetch_file(url, archive_name, timeout=30., verbose='debug') log = log.getvalue() assert 'Resuming at' not in log with open(archive_name, 'rb') as fid: data = fid.read() stop = len(data) // 2 assert 0 < stop < len(data) with open(archive_name + '.part', 'wb') as fid: fid.write(data[:stop]) with catch_logging() as log: _fetch_file(url, archive_name, timeout=30., verbose='debug') log = log.getvalue() assert 'Resuming at %s' % stop in log with pytest.raises(Exception, match='unknown url type'): _fetch_file('NOT_AN_ADDRESS', op.join(tempdir, 'test'), verbose=False) resume_name = op.join(tempdir, "download_resume") # touch file with open(resume_name + '.part', 'w'): os.utime(resume_name + '.part', None) _fetch_file(url, resume_name, resume=True, timeout=30., verbose=False) with pytest.raises(ValueError, match='Bad hash value'): _fetch_file(url, archive_name, hash_='a', verbose=False) with pytest.raises(RuntimeError, match='Hash mismatch'): _fetch_file(url, archive_name, hash_='a' * 32, verbose=False)
def test_parse_provides_useful_errors(): with raises(LanguageError) as excinfo: parse("""{""") assert ( u'Syntax Error GraphQL (1:2) Expected Name, found EOF\n' u'\n' u'1: {\n' u' ^\n' u'' ) == excinfo.value.message assert excinfo.value.positions == [1] assert excinfo.value.locations == [SourceLocation(line=1, column=2)] with raises(LanguageError) as excinfo: parse("""{ ...MissingOn } fragment MissingOn Type """) assert 'Syntax Error GraphQL (2:20) Expected "on", found Name "Type"' in str(excinfo.value) with raises(LanguageError) as excinfo: parse('{ field: {} }') assert 'Syntax Error GraphQL (1:10) Expected Name, found {' in str(excinfo.value) with raises(LanguageError) as excinfo: parse('notanoperation Foo { field }') assert 'Syntax Error GraphQL (1:1) Unexpected Name "notanoperation"' in str(excinfo.value) with raises(LanguageError) as excinfo: parse('...') assert 'Syntax Error GraphQL (1:1) Unexpected ...' in str(excinfo.value)
def test_pqueue_by_servicebus_client_iter_messages_simple(live_servicebus_config, partitioned_queue): client = ServiceBusClient( service_namespace=live_servicebus_config['hostname'], shared_access_key_name=live_servicebus_config['key_name'], shared_access_key_value=live_servicebus_config['access_key'], debug=True) queue_client = client.get_queue(partitioned_queue) with queue_client.get_receiver(idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver: with queue_client.get_sender() as sender: for i in range(10): message = Message("Iter message no. {}".format(i)) sender.send(message) count = 0 for message in receiver: print_message(message) message.complete() with pytest.raises(MessageAlreadySettled): message.complete() with pytest.raises(MessageAlreadySettled): message.renew_lock() count += 1 with pytest.raises(InvalidHandlerState): next(receiver) assert count == 10
def test_check_config(tmpdir, registry): test_path = str(tmpdir / "test.json") with open(test_path, "w+", encoding="utf-8") as f: f.write("") with pytest.raises(ApplianceError): Appliance(registry, "jkhj") with pytest.raises(ApplianceError): Appliance(registry, test_path) with open(test_path, "w+", encoding="utf-8") as f: f.write("{}") with pytest.raises(ApplianceError): Appliance(registry, test_path) with pytest.raises(ApplianceError): with open(test_path, "w+", encoding="utf-8") as f: f.write('{"registry_version": 42}') Appliance(registry, test_path) Appliance(registry, "tests/registry/appliances/microcore-linux.json")
def test_circular_cone_flat(): """Conebeam geometry with circular acquisition and a flat 2D detector.""" # Parameters full_angle = np.pi apart = odl.uniform_partition(0, full_angle, 10) dpart = odl.uniform_partition([0, 0], [1, 1], [10, 10]) src_rad = 10 det_rad = 5 with pytest.raises(TypeError): odl.tomo.CircularConeFlatGeometry([0, 1], dpart, src_rad, det_rad) with pytest.raises(TypeError): odl.tomo.CircularConeFlatGeometry(apart, [0, 1], src_rad, det_rad) with pytest.raises(ValueError): odl.tomo.CircularConeFlatGeometry(apart, dpart, -1, det_rad) with pytest.raises(ValueError): odl.tomo.CircularConeFlatGeometry(apart, dpart, src_rad, -1) # Initialize geom = odl.tomo.CircularConeFlatGeometry(apart, dpart, src_rad, det_rad) assert all_almost_equal(geom.angles, apart.points().ravel()) with pytest.raises(ValueError): geom.det_refpoint(2 * full_angle) assert geom.ndim == 3 assert np.linalg.norm(geom.det_refpoint(0)) == det_rad assert np.linalg.norm(geom.src_position(np.pi)) == src_rad assert isinstance(geom.detector, odl.tomo.Flat2dDetector) # check str and repr work without crashing and return something assert str(geom) assert repr(geom)