Hello again everyone - and thanks for your responses. Adding the
unittest method message was something I didn't realize I could do!
On Thu, May 6, 2010 at 10:20 PM, Steven D'Aprano wrote:
> With respect to Lie, dynamically adding methods is an advanced technique
> that is overkill for what you s
On Fri, 7 May 2010 03:53:08 am Damon Timm wrote:
> Hi Lie -
>
> Thanks for that idea -- I tried it but am getting an error. I read a
> little about the __dict__ feature but couldn't figure it. I am going
> to keep searching around for how to dynamically add methods to a
> class ... here is the er
On Thu, 6 May 2010 10:37:20 am Damon Timm wrote:
> class TestFiles(unittest.TestCase):
>
> # this is the basic test
> def test_values(self):
> '''see if values from my object match what they should
> match'''
> for file in FILES:
> for k, v in TAG_VA
On Thu, May 6, 2010 at 1:15 PM, Steve Willoughby wrote:
> The unit test methods all take message arguments so if you just
> want to customize the reported error, that's easily done.
>
> something like:
> self.assertEqual(self.file.tags[k], v, "Failure with key "+k)
>
> That's easiest. If you re
The unit test methods all take message arguments so if you just
want to customize the reported error, that's easily done.
something like:
self.assertEqual(self.file.tags[k], v, "Failure with key "+k)
That's easiest. If you really want a separate test for each, you
may want to create a factory
Sorry for the multiple posts ... I'll be quiet for a while until I
find a real answer!
What I wrote below doesn't actually work -- it appears to work because
all the functions have different names but they all reference a single
function ... I should have looked more closely at my initial output..
Ooh! Wait! I found another method that is similar in style and
appears to work ...
class TestFileTags(unittest.TestCase):
pass
for test_name, file, key, value in list_of_tests:
def test_func(self):
self.assertEqual(file.tags[key], value)
setattr(TestFileTags, test_name, tes
Hi Lie -
Thanks for that idea -- I tried it but am getting an error. I read a
little about the __dict__ feature but couldn't figure it. I am going
to keep searching around for how to dynamically add methods to a class
... here is the error and then the code.
Thanks.
# ERROR:
$ python tests_ta
On 05/06/10 10:37, Damon Timm wrote:
> Hi - am trying to write some unit tests for my little python project -
> I had been hard coding them when necessary here or there but I figured
> it was time to try and learn how to do it properly.
>
> This test works, however, it only runs as *one* test (whi
Hi Vincent - Thanks for your input.
Where would I put that string ? In the function's doctsring ? Or
just as a print method ?
I have been looking online some more and it appears there may be a way
to create some sort of generator ... it's still a little confusing to
me, though. I was hoping th
By they way you shouldn't need to use str(file) as I did. Unlessit is
not a string already. Bad habit. I am used to numbers
vincet
On Thursday, May 6, 2010, Vincent Davis wrote:
> I can't think of a way to do what you ask, without defining a test for each.
> ButI think what you might actually wa
I can't think of a way to do what you ask, without defining a test for each.
ButI think what you might actually want is the define the error message to
report which one failed. ie, it's one test with a meaningful error message.
'Failed to load' + str(file)+' '+ str(k)+', '+str(v)
I am not ecpert on
Hi - am trying to write some unit tests for my little python project -
I had been hard coding them when necessary here or there but I figured
it was time to try and learn how to do it properly.
I've read over Python's guide
(http://docs.python.org/library/unittest.html) but I am having a hard
time
13 matches
Mail list logo