Re: Mock object but also assert method calls?

2015-08-15 Thread Thomas Lehmann via Python-list
Am Freitag, 14. August 2015 04:53:56 UTC+2 schrieb Steven D'Aprano: > On Fri, 14 Aug 2015 07:21 am, Ben Finney wrote: > > >> If find following totally different to the normal API which > >> is provided by the mock library: > >> > >> assert call().test2("hello") in mocked_objects.mock_calls > > >

Mock object but also assert method calls?

2015-08-13 Thread Thomas Lehmann via Python-list
Hi, How about asserting that test2 of class Bar is called? Of course I can do a patch for a concrete method but I was looking for something like: mocked_object.assert_method_called_with(name="test2", "hello") If find following totally different to the normal API which is provided by the mock

bdist_rpm with --requires and version

2014-11-07 Thread thomas . lehmann
Hi, using the RPM build I wonder how I can require a certain version of another RPM like: Working: python setup.py bdist_rpm --requires=another-package But how to? ... python setup.py bdist_rpm --requires=another-package>=2.1 Of course this will generate a "=2.1" file which is of course not

Re: Why Python 3?

2014-05-06 Thread Thomas Lehmann
Hi, I can't give you the advise for a concrete version anyway there are lot of arguments given by the other posters. BUT there is a way how you can circumvent the problem to some extend: Are you intending to use Jenkins? I don't want to convince you here why to use Jenkins but maybe I don't ne

xmlrpc: problems with socket handling, close, shutdown of server, TIME_WAIT, ...

2014-05-06 Thread thomas . lehmann . private
Hi, taking the xml-rpc derived from standard example is working - basically - but with following scenario I do not understand the problem. Maybe you can help: - one Unittest that does create the xmlrpc server in a thread in "setUp" and shutdown of it in tearDown. The xml-rcp server does s

Pylint across Python versions

2014-02-10 Thread thomas . lehmann
Hi, somebody who can tell me about pylint experiences across different Python version. Example: I'm using a construct like this: if sys.version.startswith("3."): unicode = str The reason is that Python 3 does not have this function anymore but pylint yells for Python < 3 about redefinition

Python RPM distribution with altinstall on Centos 5

2013-11-19 Thread thomas . lehmann
Hi all, I missed to find a Python 2.7.6 Centos 5 distribution. Here's what I planned to do: - building from source on Centos 5 in a chroot (is working fine) - using "sudo make altinstall" (is working fine) But ... - I want to build this via Jenkins (we have this kind of chroot build's sti

Re: Decode II (more complex)

2010-06-21 Thread Thomas Lehmann
> Your email(s) get send as 7 bit (ASCII). Email them as utf-8 and I guess > your problem is solved. > > How do you email the notifications? > I was copying partly the logic from http://code.activestate.com/recipes/473810 Changing to buffer.decode("utf-8", 'replace') where I'm reading the file a

Re: deduping

2010-06-21 Thread Thomas Lehmann
> universe={} > for line in outf: >     if line.split(',')[1].strip() in universe.keys(): >         a=1 >     else: >         if line.split(',')[1].strip() in done_.keys(): >             a=1 >         else: >             universe[line.split(',')[1].strip()]=0 > I can not say too much because I don

Decode II (more complex)

2010-06-21 Thread Thomas Lehmann
Hi all, I have written a small python xmlrpc server which checks logfiles of a build sending notifications to the responsible teams. On a machine I'm forced to a problem with one logfile with special characters inside generated by a gnu compiler. Using cheetah for generating the HTML mail I get a

Advanced Dictionary

2010-06-16 Thread Thomas Lehmann
Hi, I have seen a recipe which allows auto creation of missing values for dictionaries. However this recipe is not working for all. class AutoValueDict(dict): def __makeitem__(self, key): return self.setdefault(key, {}) def __getitem__(self, key): return self.get(key, sel

Re: Advanced Dictionary

2010-06-16 Thread Thomas Lehmann
> > class AutoValueDict(dict): >     def __makeitem__(self, key): >         return self.setdefault(key, {}) > >     def __getitem__(self, key): >         return self.get(key, self.__makeitem__(key)) > > I would like to have a dictionary which ensures dictionaries as values > except when I'm assigni

Re: Problem with an huge dictionary

2010-05-20 Thread Thomas Lehmann
> > The question is: > Is there a limit on the number of entries a dictionary can have i > jython? > > I wrote a little app where my data is stored in a huge dictionary > (11746 entries) generated with a python script. > When I try to import the dictionary, jython complains with the > following mes

Re: intervall of about 1 second for xmlrpc calls?

2010-05-20 Thread Thomas Lehmann
> What's wrong? > Obviously there's a problem with "localhost". When using the IP of my machine everything is working fast. -- http://mail.python.org/mailman/listinfo/python-list

intervall of about 1 second for xmlrpc calls?

2010-05-20 Thread Thomas Lehmann
Hi, I'm wondering about the behavior. Running this example - it looks like - that each rpc call is triggered in a visible interval (about one second). What's wrong? Thomas APPENDIX: import threading from xmlrpc.server import SimpleXMLRPCServer import xmlrpc.client class MyServer(threading.Th

Re: No module named server

2010-05-07 Thread Thomas Lehmann
On 7 Mai, 10:02, Thomas Lehmann wrote: > > Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit > > Also after installing Python 3.1.2 the problem is still there. I know the problem. Reading a book about a simple cgi web server the descriptions says to use httpd.py

Re: No module named server

2010-05-07 Thread Thomas Lehmann
> Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit Also after installing Python 3.1.2 the problem is still there. -- http://mail.python.org/mailman/listinfo/python-list

No module named server

2010-05-07 Thread Thomas Lehmann
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Script: from http.server import HTTPServer, CGIHTTPRequestHandler Result: Traceback (most recent call last): File "http.py", line 1, in from http.server import HTTPServer, CGIHTTPRequestHandler File "F:

SAX: Short tag's ...

2009-10-05 Thread Thomas Lehmann
Hi! Is there a way to recognize short tags in a XML? I'm implementing a SAX handler... Problem: storing the XML code I would need this information in the startElement ... How can I handle this? any text -- http://mail.python.org/mailman/listinfo/python-list

Re: weak reference to bound method

2009-10-02 Thread Thomas Lehmann
> I am trying to use a weak reference to a bound method: > > class MyClass(object): > def myfunc(self): > pass > > o = MyClass() > print o.myfunc > > > > import weakref > r = weakref.ref(o.myfunc) > print r() > None > > This is what I do not understand. The object "o" is s

Re: Tkinter - Text - bullets

2009-09-21 Thread Thomas Lehmann
> This is probably why you had all these alignment problems. But it's > weird, because the script I posted is copied and pasted from a really > script that I've run, and which doesn't cause any error. What is the > version of tcl/tk used by your Tkinter module? And what is your Python > version? U

Re: Tkinter - Text - bullets

2009-09-19 Thread Thomas Lehmann
> Something like this maybe? > > from Tkinter import * > > root = Tk() > txt = Text(root, wrap='word') > txt.pack() > > txt.tag_configure('text_body', font=('Times', 18), lmargin1=0, > lmargin2=0) > txt.tag_configure('bulleted_list', font=('Times', 18), lmargin1='10m', > lmargin2='15m', tabs=[

Tkinter - Text - bullets

2009-09-18 Thread Thomas Lehmann
My intention is to write a small custom widget displaying text where the text can have a simple wiki syntax. The main interest is to support heading, bold, italic, underline, itemization and enumeration. How can I implement itemization using the Tkinter.Text widget? (bullets) -- http://mail.pytho

Re: Zipped and pickle

2009-09-16 Thread Thomas Lehmann
> Briefly: > > s = cPickle.dumps(obj) > z = zipfile.Zipfile("filename.zip","w",zipfile.ZIP_DEFLATED) > z.writestr("arcname.pkl",s) Thank you very much. I have not been aware that pickle can also do the job without a file! Here's the complete scenario for writing and reading the data... APPENDIX:

Re: Fwd: Re: How to improve this code?

2009-09-16 Thread Thomas Lehmann
> otherwise. Given this, I'm just trying to write a method > are_elements_present(aList) whose job is to return True if and only if > all elements in aList are present in page's HTML. So here is how > missingItems = [str(ele) for ele in eleLocators if not selenium.is_element_present(ele)] if len(m

Zipped and pickle

2009-09-16 Thread Thomas Lehmann
How do I implement best to use pickle that way that the file is zipped? -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter only: table widget with canvas...

2009-07-11 Thread Thomas Lehmann
> > There's a working app at http://cl1p.net/tkinter_table_headers/ > > -John Thank you for this example. However, one issue to that... When resizing the window (vertical) then the header moves away from the table. How can I avoid this with the grid? With "pack" I now this... -- http://mail.pytho

Tkinter only: table widget with canvas...

2009-07-10 Thread Thomas Lehmann
My intention is to keep dependencies low that means using python and tkinter as base package is quite easy because it's available on nearly every system. There is good documentation on Tkinter but going into the depth I'm missing many details. As an example... Using the Tkinter.Canvas class I sho

Re: Beginning with Python; the right choice?

2009-06-27 Thread Thomas Lehmann
> read and have started to go through them.  I was wondering, as someone > with virtually no programming experience (I am a photographer by > trade), is Python the right language for me to try and learn? Well, I'm a 100% C++ programmer but I like programming python for prototyping and tools. The

Fast Dictionary Access

2009-06-27 Thread Thomas Lehmann
Hi! In C++, programming STL you will use the insert method which always provides a position and a flag which indicates whether the position results from a new insertion or an exisiting element. Idea is to have one search only. if data.has_key(key): value = data[key] But this does mean (doe