11-24-2023 10:09 AM
Hello,
I was trying to run the following test parser and it seems that there is an issue with the search type under the ConfigParserVLAN.
Please see details below.
Thanks.
python3 -m unittest test_parser_customer_vlan.py
ConfigurationParser
Accessed ConfigParser Module
E
======================================================================
ERROR: test_parse_cust_vlan (test_parser_customer_vlan.TestParse)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/cisco/test_parser_customer_vlan.py", line 11, in test_parse_cust_vlan
parsed_vlan = cp.parseCustomerVlan(customer_name)
File "/cisco/ConfigParserVLAN.py", line 12, in parseCustomerVlan
allCustomerSubInterfaces = re.search(intPattern, self.deviceConfig)
File "/usr/lib/python3.10/re.py", line 200, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (errors=1)
%%%%%%%%%%%%%%%%%%%%%%%%%%
test_parser_customer_vlan.py
11-25-2023 03:35 AM
@Netmart looks like you need to read the contents of the config.txt file into a string before calling re.search. Try using the open() function's read() method.
Hope this helps
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide