omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How to use pytest (level beginner)

    Pythonista
    1
    1
    2838
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • runjaj
      runjaj last edited by runjaj

      Hi!

      My knowledge of Python and Pythonista is frankly low. Maybe you'll find this too easy and evident, but I've needed sometime to understand how to use pytest in Pythonista.

      Here is an script showing how to use it:

      import pytest
      
      def cuadrado(x):
          return x*x
      
      def test():
          assert(cuadrado(2)==5)
          
      pytest.main()
      

      Just import pytest and import or define your functions. Then, define your test and, finally, put pytest.main() to run the tests. That last line was the thing I couldn't find when I was reading the pytest tutorial.

      Javier
      Ps. Sorry for the bad English.

      1 Reply Last reply Reply Quote 4
      • First post
        Last post
      Powered by NodeBB Forums | Contributors