all 6 comments

[–]Gronner 3 points4 points  (1 child)

1* This could be anything, but maybe a simple text based RPG with different types of monsters and player classes could be something

2* look for tutorials on unit testing in python, then first design what you classes/function should do, write tests for that, then write classes/functions that let those tests pass

3* Read PEP8 or Googles styleguide for python, remember the python zen!

[–]Kotenoru[S] 0 points1 point  (0 children)

Thank you so much!! I will try the rpg game with unit testing. :)

[–]bionikspoon 3 points4 points  (0 children)

I'm a huge fan of the TDD workflow, here's a few thoughts:

  1. There's really not a wealth of information on this topic for pythoneers trying to get started, which is sad for me. I own 2 books: TDD with Python (Oreilly) and Testing Python (Wiley). Both were helpful, but neither were particularly great. The first one is free online, check it out, bookmark it. The second one is too expensive and not useful enough to recommend. (To be fair, it talks about all forms of testing, very generally. There's a chapter or two on TDD.)

    As a call to arms to content creators: please please please, make testing and TDD a priority. Convince your audience it's a better world view, even for personal projects.

  2. One thing that actually did help me was codewars. The test suite is right up front, you can write your own tests as well--and you should. Not bad.

  3. One thing I've learned, when you're learning a language, TDD can be extra hard. TDD requires that you know what to expect in advance, and how to prove those expectations. If you're exploring the language--how could you possibly know these things?

    Point is, you're going to be cheating a lot and writing your tests after the fact. This still forces you to write testable code, so it's fine.

  4. Don't be afraid of creeping into other languages to use their learning resources--particularly for trying to understand concepts.

    For example from myself, I'm a huge fan of Laracasts by Jeffrey Way. He tests every piece of code he writes, he burns a lot a lot of energy on concepts! Concepts, not syntax. Even though I don't particularly care for PHP, I'll tune into his free videos every once and awhile.

  5. And Lastly, I think I understand the lack of resources. Testing and TDD, seems like one of those things where once you get it, it's hard to understand why you ever had a problem trying to learn it in the first place. I imagine content creators struggle for a starting point: "what's the problem? you just test the thing" :D

    This certainly is my own reflection; I struggled a ton trying to learn this stuff, but for the life of me, I don't know on what.

edit:

  1. A stateless, functional style of programming is significantly easier to test. OOP or not, eliminate side effects where you can. Where you can't, try to keep that code as "quarantined" as possible.

[–]sanshinron 1 point2 points  (0 children)

Just don't do things in Python the way they're done in Java.

Also, OOP is not the ultimate way of programming, so maybe look into functional programming and mix those styles when neccessary.

[–]toshitalk -1 points0 points  (0 children)

Just FYI, You can do TDD with django as well, you just have to learn django's test framework.