From 31135028dc651d8914fb7ee96328be21aeb616be Mon Sep 17 00:00:00 2001 From: jurraca Date: Mon, 25 Nov 2024 11:21:52 +0000 Subject: [PATCH] handle IPv6 in test extra_df generation --- tests/merge_base_class_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/merge_base_class_test.py b/tests/merge_base_class_test.py index 748ff2e..15940ea 100644 --- a/tests/merge_base_class_test.py +++ b/tests/merge_base_class_test.py @@ -7,8 +7,13 @@ def _df_from_network(network, asn=123): ''' Create a one-row dataframe that holds the extra file rows in the expected format for contains_row(). ''' - root_net = int(network.split(".", maxsplit=1)[0]) - network_int = int(ipaddress.ip_network(network).network_address) + ipn = ipaddress.ip_network(network) + v = ipn.version + if v == 4: + root_net = int(str(pfx).split(".", maxsplit=1)[0]) + else: + root_net = int(str(pfx).split(":", maxsplit=1)[0]) + network_int = int(ipn.network_address) df_extra = pd.DataFrame( data={"INETS": network_int, "ASNS": asn, "PFXS": network, "PFXS_LEADING": root_net}, index=[0],