#144 Are you mocking me? It won't work!

Python Bytes - Podcast tekijän mukaan Michael Kennedy and Brian Okken - Maanantaisin

Kategoriat:

Sponsored by DigitalOcean: pythonbytes.fm/digitalocean

Chris #1: Why your mock doesn’t work

  • Ned Batchelder
  • TDD is an important practice for development, and as my team is finding out, mocking objects is not as easy at it seems at first.
  • I love that Ned gives an overview of how Mock works
  • But also gives two resources to show you alternatives to Mock, when you really don’t need it.
  • From reading these articles and video, I’ve learned that it’s hard to make mocks but it’s important to:
    • Create only one mock for each object you’re mocking
    • that mocks only what you need
    • have tests that run the mock against your code and your mock against the third party

Mahmoud #2: Vermin

  • By Morten Kristensen
  • Rules-based Python version compatibility detector
  • caniuse is cool, but it’s based on classifiers. When it comes to your own code, it’ll only tell you what you tell it.
  • If you’ve got legacy libraries, or like most companies, an application, then you’ll need something more powerful.
  • Vermin tells you the minimum compatible Python version, all the way down to the module and even function level.

Brian #3: The nonlocal statement in Python

  • Abhilash Raj
  • When global is too big of a hammer.
  • This doesn’t work:
    def function():
        x = 100
        def incr(y):
            x = x + y
        incr(100)
  • This does:
    def function():
        x = 100
        def incr(y):
            nonlocal x
            x = x + y
        incr(100)
        print(x)

Chris #4: twitter.com/brettsky/status/1163860672762933249

  • Brett Cannon
  • Microsoft Azure improves python support
    • 2 key points about the new Python support in Azure Functions:
      • it's debuting w/ 3.6, but 3.7 support is actively being worked on and 3.8 support won't take nearly as long, and
      • native async/await support!

Mahmoud #5: Awesome Python Applications update

Brian #6: pre-commit now has a quick start guide

  • Wanna use pre-commit but don’t know how to start? Here ya go!
  • Runs through
    • install
    • configuration
    • installing hooks
    • running hooks against your project
  • I’d like to add
    • Add hooks to your project one at a time
    • For each new hook
      • add to pre-commit-config.yml
      • run pre-commit install to install hook
      • run pre-commit run --``all-files
      • review changes made to your project
        • if good, commit
        • if bad
        • revert
        • modify config of tools, such as pyproject.toml for black, .flake8 for flake8, etc.
        • try again

Extras

Chris:

Mahmoud:

  • PyGotham 2019 October (Maintainers Conf in Washington DC, too)
  • Real Python Pandas course

Brian:

Jokes

  • I was looking for some programming one liners online; looked on a reddit thread; read a great answer; which was “any joke can be a one-liner with enough semicolons.”
  • A SQL statement walks into to a bar and up to two tables and asks, “Mind if I join you?”

Visit the podcast's native language site