Python Forum
Can I get a clue about testing please?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I get a clue about testing please?
#1
I am picking up Python in a serious way, these days.
While reading through the syntax and standard libraries, I am also super-curious about the Python ecosystem.

In particular, I want to write code that is all unit-tested and then create repo's that enforce integration-testing.
Then, I want to have, like, functional testing suites for more end-to-end testing.

I have lots of experience with Java-JUnit-Maven and was wondering if Python adopts a similar build-test-deploy model or has some new patterns for me to learn?

Also, I've initially looked into the 'unittest' module. I've written some unit tests for my example application, ran those in the IDE, observed results... OK, that's cool :)

Then, I was interested in integrating my example application into a CI-CD system and wrote a little github workflow YAML file that sets up, builds and then runs tests - but that was using the 'pytest' module.

Is 'pytest' a "competitor" to 'unittest' or a complement (and, in that case, what is each used for?)?

'unittest' was kinda easy for me to understand, because it feels a lot like JUnit but in Python...
'pytest' was a little more obscure, as it uses a lot of standard folder and file names, which you need to know about in order to configure it correctly... But once I managed, it does look more sleek.

Yeah, I see my question is a bit broad and messy. I am just going to appreciate any discussion, idea, suggestion, etc :)
Reply
#2
Have you read the python.org write-up?
If not start here: https://docs.python.org/3/library/unittest.html
Then there are many tutorial available which you can easily find with google.
Reply
#3
Yes, that's where I started.
However, I was hoping for input from people who write commercial-grade code - for example: is 'unittest' preferable to 'pytest'?
Reply
#4
I have written commercial software, and use python's unit test.
pytest was released on April 3 of this year.
I'll give it some time to prove itself before using.
Reply
#5
oh wow, lucky me - I joined something before it became super common place - maybe I will be the leading pytest expert! :)

Thanks for that bit, it helps to make the right choice
Reply
#6
ah, sorry, are we talking about the same thing:
https://docs.pytest.org/en/stable/change...#changelog
("2009", etc...)
Reply
#7
(Apr-12-2021, 09:40 AM)Larz60+ Wrote: pytest was released on April 3 of this year.
No and no⏰
pytest version 1.0.0 (2009-08-04)

For me it always pytest it reduces boilerplate code to the minimum,
and is much more pythonic than unittest which has to much flavors from Java JUnit.
Reply
#8
(Apr-12-2021, 09:40 AM)Larz60+ Wrote: pytest was released on April 3 of this year.
I'll give it some time to prove itself before using.
well, pytest is well established test framework - ver 6.4.3 was release on 4 April 2021

@Mustey, I would say pytest is "competitor" to unittest (I hope you put same meaning). pytest is easy to start with and I like it. Give it a try.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
OK, my mistake. I was looking at this page: https://pypi.org/project/pytest/
it shows release date: Apr 3, 2021, but I realize now that is for version 6.2.3
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I have no clue what I am doing wrong here elroberto 4 1,332 Jun-18-2022, 08:56 PM
Last Post: deanhystad
  I haven't a clue how to implement this logic 357mag 3 2,067 Apr-02-2020, 04:35 PM
Last Post: 357mag
  Getting syntax error, no clue why KaynRyu 4 3,083 Mar-26-2019, 02:43 PM
Last Post: KaynRyu
  I have no clue whats wrong... Jack_03 1 2,785 Sep-28-2017, 05:36 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020