473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Assertion in Python

Hi All,

I want to do verification in my scripts. So for that what i am doing
here are shown below:

1. Telnet to one router.
2. Configure router.
3. Configure routing.

Now after doing all these i have to check showinterfaces. So i execute
command show interface and saved the output in one file.

Now the problem which i am facing is how to do assertion from that
output. e.g output is something like this

eth0 is up
OSPF not enabled on this interface
eth1 is up
Internet Address 192.168.1.2/24, Area 0.0.0.0
Router ID 192.168.1.2, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.1.2, Interface Address 192.168.1.2
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
Neighbor Count is 0, Adjacent neighbor count is 0
eth2 is up
OSPF not enabled on this interface
eth3 is down
OSPF not enabled on this interface
lo is up
OSPF not enabled on this interface
sit0 is down
OSPF not enabled on this interface

In this i want to check Designated Router (ID) 192.168.1.2.

If this is the same Ip which i have gice in configuration then test
case will get pass otherwise Fail.

Can somebody send me the code how to do this.

Thanks in Advance
Vikram Malhotra

Oct 5 '06 #1
1 1403
At Thursday 5/10/2006 04:09, vmalhotra wrote:
>Now the problem which i am facing is how to do assertion from that
output. e.g output is something like this

eth0 is up
OSPF not enabled on this interface
eth1 is up
Internet Address 192.168.1.2/24, Area 0.0.0.0
Router ID 192.168.1.2, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.1.2, Interface Address 192.168.1.2
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
Neighbor Count is 0, Adjacent neighbor count is 0
eth2 is up
OSPF not enabled on this interface
eth3 is down
OSPF not enabled on this interface
lo is up
OSPF not enabled on this interface
sit0 is down
OSPF not enabled on this interface

In this i want to check Designated Router (ID) 192.168.1.2.
This is the idea (assuming you have already read and split the output
on lines):

for line in output:
line = line.strip()
if line.startswith('Designated Router (ID)'):
ipReadStr = line[line.find('(ID)')+4:] # just before the IP starts
ipReadStr = ipReadStr.split(',',1)[0].strip() # up to the next ","
assertEqual(ipReadStr, ipExpected)
break
else:
fail('"Designated Router (ID)" not found')
Gabriel Genellina
Softlab SRL

__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Oct 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Todd Miller | last post by:
Hi, I recently discovered an assertion failure in the Python garbage collection system when scripts using our C extension (numarray) exit. The assertion is activated for Pythons configured using...
0
by: benevilent | last post by:
Hey, I'm getting an assertion error as a result of embedding python. "Modules/gcmodule.c:231: visit_decref: Assertion `gc->gc.gc_refs != 0' failed." I only get this assertion error with...
4
by: Morgan Leppink | last post by:
Hey all - We are running SQL 2000 with ALL available service packs, etc. applied. We just built a brand new database server, which has dual 2Ghz XEONs, 2GB memory, and the following disk...
2
by: alexLIGO | last post by:
Hi, I got this error when trying to execute the following python command with in a C module: Py_BuildValue Do anyone have any idea what this error is about? And does anyone have any idea how...
1
by: Timur Safin | last post by:
Hi All, Sorry if it is offtopic here, I wasn't able to find any more relevant group... I'm slowly approaching AMD64 build for our product (as my personal fun project). And after I ran that...
5
by: Ron Louzon | last post by:
I have some C++ code that uses the CSingleLock( CCriticalSection *) constructor. In visual C++ 6.0, this code compiles and runs fine in both Debug and release modes. However, in Visual Studio...
4
by: Mullai | last post by:
Hi , My program gives an error message like this Debug Assertion Failed! program:................ File: wincore.cpp Line: 958 Please can anyone help me out in this issue. I have to solve...
11
by: beginner | last post by:
Hi, Does anyone know how to put an assertion in list comprehension? I have the following list comprehension, but I want to use an assertion to check the contents of rec_stdl. I ended up using...
9
by: matthias | last post by:
Howdy ! I started using the assert() stmt and found it quite useful :-) I have only one problem: I don't know how to turn them off again. I know that "-O" turns off assertions in general. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.