Logo QF-Test

Im Archiv der Mailingliste
wertvolle Antworten finden.

 

Gratis Testen  Download  Kaufen

Thomas Max, QF-Test Training und Support

Tipp für die Recherche in der Mailingliste: Volltextsuche (oben) verwenden.

Thomas Max,
Sr. Software Engineer & Trainer, QFS

2016 bis heute 2015 | 2014 | 2013 | 2012 | 2011 2010 2009 | 2008 | 2007

(ältere Archiveinträge vor 2007 nicht dargestellt, aber in der Suche enthalten)

Mailingliste - Einträge 2007


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] Help required to typecast String to List in SUT Script


  • Subject: Re: [QF-Test] Help required to typecast String to List in SUT Script
  • From: "Robert Lahmer, QFS support" <support@?.de>
  • Date: Fri, 11 May 2007 13:30:05 +0200



Hello Alfred,

your QF-Test variable globalList is a string, so I think a simple typecast
won't help. But you can split the string into its elements like this:

import string

globalList="'172.31.11.181','172.26.20.158','172.31.11.184'"
globalList = string.replace(globalList, "'", "")
# split returns a list - make a tuple of it, if you like
IPList=tuple(string.split(globalList,","))
print type(IPList)
print IPList
list=list(IPList)
print len(list)
print list


The output is:

org.python.core.PyTuple
('172.31.11.181', '172.26.20.158', '172.31.11.184')
3
['172.31.11.181', '172.26.20.158', '172.31.11.184']


Best regards,
   Robert



--On Freitag, Mai 11, 2007 02:51:13 -0600 Alfred Mathavan
<amathava@?.com> wrote:

Hi All,



I have configured JYDT (Jython Development Tool) in eclipse v3.2

Click here -> http://www.redrobinsoftware.net/jydt/ for more information
on JYDT.



After Configuration of JYDT in Eclipse I am able to develop and execute
Jython programs in Eclipse IDE.



For E.g.:

IPList='172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','
172.31.11.186','172.31.11.183',

print type(IPList)

print IPList



list=list(IPList)

print len(list)

print list



Output:

<type 'tuple'>

('172.31.11.181', '172.26.20.158', '172.31.11.184', '172.31.11.200',
'172.31.11.186', '172.31.11.183')

6

['172.31.11.181', '172.26.20.158', '172.31.11.184', '172.31.11.200',
'172.31.11.186', '172.31.11.183']



When I try to get the same with QF-Test SUT Script with a slight change
in the IPList variable type I goof up.

I am not sure how to typecast a String variable to a tuple (or) List.



In QFTest I have a variable called globalList with the value
'172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.31.
11.186','172.31.11.183',



I try to get the same output that I got in Eclipse from my SUT Script.



The 2 approaches that I tried are:-

Approach 1

IPList=globalList

print type(IPList)

print IPList



list=list(IPList)

print len(list)

print list

Output 1

org.python.core.PyString

'172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.31.
11.186','173.34.3.3','172.31.11.183',

109

["'", '1', '7', '2', '.', '3', '1', '.', '1', '1', '.', '1', '8', '1',
"'", ',', "'", '1', '7', '2', '.', '2', '6', '.', '2', '0', '.', '1',
'5', '8', "'", ',', "'", '1', '7', '2', '.', '3', '1', '.', '1', '1',
'.', '1', '8', '4', "'", ',', "'", '1', '7', '2', '.', '3', '1', '.',
'1', '1', '.', '2', '0', '0', "'", ',', "'", '1', '7', '2', '.', '3',
'1', '.', '1', '1', '.', '1', '8', '6', "'", ',', "'", '1', '7', '3',
'.', '3', '4', '.', '3', '.', '3', "'", ',', "'", '1', '7', '2', '.',
'3', '1', '.', '1', '1', '.', '1', '8', '3', "'", ',']





Approach 2

            IPList=[globalList]

print type(IPList)

print IPList



list=list(IPList)

print len(list)

print list

Output 2

org.python.core.PyList

["'172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.3
1.11.186','173.34.3.3','172.31.11.183',"]

1

["'172.31.11.181','172.26.20.158','172.31.11.184','172.31.11.200','172.3
1.11.186','173.34.3.3','172.31.11.183',"]



Any help to get the exact list from the SUT Script?



Greetings,

Alfred









--
Robert Lahmer
Quality First Software GmbH                http://www.qfs.de
Tulpenstr. 41                           Tel: +49 8171 919874
DE-82538 Geretsried                     Fax: +49 8171 919876
GF: Gregor Schmid, Karlheinz Kellerer     HRB München 140833




Videos Downloads Dokumentation Kaufen Gratis Testen