Let's build a PYTHON UNIT TEST framework! | part 1

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 10

  • @NotOnlyCode
    @NotOnlyCode  3 роки тому +1

    If you enjoyed this walkthrough make sure to check part 2 where I'm adding an assertion library: ua-cam.com/video/dl_vjsG2F8E/v-deo.html, and later this month I'm planning to release part 3

  • @adarshbattu1568
    @adarshbattu1568 2 роки тому

    Really cool 😎

  • @zoranagavrilovic9403
    @zoranagavrilovic9403 2 роки тому

    gold, thank you so much

  • @dimitarganev7797
    @dimitarganev7797 3 роки тому

    Nice one! I think it would be better to use `finally/else` along with try and except. Also an interesting addition would be to evaluate the code using the `ast` and give the proper tracebacks and where it fails.

    • @NotOnlyCode
      @NotOnlyCode  3 роки тому +1

      Thanks for great ideas! I've looked at the ast module, I'm certainly going to play with it, and hopefully will add this feature too, so that it works similarly to pytest.
      Regarding finally/else, what code would you add to the "else" block? I could put printing the success message there, but I'm not sure how that makes it better, so I guess you had some other idea

    • @dimitarganev7797
      @dimitarganev7797 3 роки тому

      @@NotOnlyCode Yeah my idea was to put the success message in the `else` block, I think that it would make more coherent code, I am not aware if it's going to be better like performance wise (or if it is it shouldn't be notable).

  • @gopabhattacharyya5025
    @gopabhattacharyya5025 2 роки тому

    machinery.SourceFileLoader is depricated since python 3.6; it's mentioned in the documentation.
    How to import the modules from command line now :(

    • @NotOnlyCode
      @NotOnlyCode  2 роки тому +1

      The class is not deprecated, only the "load_module" method. I use "exec_module" which is recommended replacement since Python 3.6

    • @gopabhattacharyya5025
      @gopabhattacharyya5025 2 роки тому

      @@NotOnlyCode VS Code is not able to recognize importlib.machinery.sourceFileLoader :(

    • @NotOnlyCode
      @NotOnlyCode  2 роки тому +1

      Maybe you have a typo? It should be "importlib.machinery.SourceFileLoader" (capital "S" in "Source"). Other than that no idea what it could be, I just opened that file in VScode and it finds the file