Skip to content

Instantly share code, notes, and snippets.

@dishbreak
Created May 12, 2019 17:34

Revisions

  1. dishbreak created this gist May 12, 2019.
    19 changes: 19 additions & 0 deletions test.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import os
    import mock


    class AnyStringEndingWith(object):
    def __init__(self, suffix):
    self.suffix = suffix

    def __repr__(self):
    return "<a string ending with '%s'>" % self.suffix

    def __eq__(self, other):
    return other.endswith(self.suffix)


    @mock.patch("os.path")
    def test_matcher(mock_path):
    mock_path.isfile(os.path.join("not", "a", "real", "path"))
    mock_path.isfile.assert_called_with(AnyStringEndingWith("path"))