Jul 22, 2016 15:13
Funnily enough I'm a QA engineer for Python, so I should probably answer the question... can you link it to me here I closed the tab.
Jul 22, 2016 15:10
I'm technically at work so can't be doing too many things at once.
Jul 22, 2016 15:09
I can guarantee you there's already an answer for this but I just didn't want to look for it ;P
Jul 22, 2016 15:08
Good luck, I'll keep the chat open for a while, just ping me.
Jul 22, 2016 15:08
I'm glad :)
Jul 22, 2016 15:08
Then when you do a unittest run you don't care about the interface of zipfile, you just use it as you intend and test your own object's response to the interface
Jul 22, 2016 15:07
Yep
Jul 22, 2016 15:07
And it's not like you're doing actual work, you're just returning values you want.
Jul 22, 2016 15:06
Only the relevant parts you need which is usually less than the complete package.
Jul 22, 2016 15:04
sure
Jul 22, 2016 15:04
The basic idea of mocking is to keep everything contained so that when something goes wrong we know it's our stuff not someone elses.
Jul 22, 2016 15:03
And then in the mocked file object you just mock the methods you use like read, close, etc.
Jul 22, 2016 15:03
and another is to raise an exception that the file isn't found
Jul 22, 2016 15:03
Which in one case is return a mocked "file" object
Jul 22, 2016 15:02
Okay so you would mock out whatever module you're using to open the file or mock the file/open function to do what you want
Jul 22, 2016 15:02
Is the file attribute an actual file on the file system?
Jul 22, 2016 15:01
And try to keep it down to one assert per test, but having multiple that are similar is okay. That makes it so that when a test fails you know EXACTLY what went wrong
Jul 22, 2016 15:01
including exceptions.
Jul 22, 2016 15:01
And if there's branching/decisions within that method, there should be one test that covers each decision
Jul 22, 2016 15:00
There should be at least one unit test per method
Jul 22, 2016 15:00
It's a good idea to mock them out, just to make testing small things quicker
Jul 22, 2016 15:00
You can do simple tests in unittests without mocking, but once the OS is involved or stuff that takes a long time like requesting things from the network, etc
Jul 22, 2016 14:59
Unit-tests are usually only testing one object or module
Jul 22, 2016 14:59
Integration tests?
Jul 22, 2016 14:59
So CI tests, which hopefully you outsource to travis or something, those ones can do all the creation and deletion and stuff
Jul 22, 2016 14:58
Yeah
Jul 22, 2016 14:58
Unit tests are super low-level, meaning they usually only deal with one object interface
Jul 22, 2016 14:58
So the biggest thing I think that will help is that there are multiple levels of tests
Jul 22, 2016 14:57
Sure!
Jul 22, 2016 14:55
I believe that examining mock would greatly help you with this type of issue. Unit tests are so low level that it's beneficial to get abstract away any function that uses something on the OS (like the file system) and the mock module provides the functionality and framework for creating "fake" constructs (modules, objects, instances) that return pre-determined values allowing you to better test the interface of your design and how your interfaces work together. The proper time to actually test the internal workings of your functions is during CI tests. (Think Travis if you're on Github)
Jul 22, 2016 14:55
For instance, you can mock the os module's listdir() function to return a pre-determined amount for the single unit test without actually having to construct a directory with those files. Etc etc.
Jul 22, 2016 14:55
Have you considered mocking the object?
Jul 22, 2016 14:55
I provided a link in my comment, I just figured I'd give you the language (I didn't know the mock module existed until a few years ago) to find potentially good resources. Maybe google "python mock examples".
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Jul 21, 2016 19:32
Which IDE are you using?
Jul 21, 2016 19:30
Mines working from command line.
Jul 21, 2016 19:29
Executing from command line or import?
Jul 21, 2016 19:26
What are you executing in the pool?
Jul 21, 2016 19:24
Those namespace collisions, I wish they would have not named the logging module logging, because having a file called logging.py is not an uncommon want.
Jul 21, 2016 19:23
Hahaha, that's definitely the issue.
Jul 21, 2016 19:22
Wait why is multiprocessing in that list?
Jul 21, 2016 19:21
@xxmbabanexx What shows up if you enter in dir(multiprocessing) after importing multiprocessing?
Jul 21, 2016 19:18
Try from multiprocessing.dummy import Pool.
Jul 21, 2016 19:16
You can't even import it?
Jul 21, 2016 19:16
@xxmbabanexx It works on my Python 2.7.5.
Jul 21, 2016 19:15
@xxmbabanexx What Python version?
Jul 21, 2016 18:25
@poke My one complaint: the Transfer button is at the BOTTOM of the Pokemon about page. It should be at the top, most clicked button in the game.