def test_expired_token_returns_none(self, opener, is_token_expired):
        """Test that an expired token returns None."""
        scope = "playlist-modify-private"
        path = ".cache-username"
        expired_tok = _make_fake_token(0, None, scope)

        token_file = _token_file(json.dumps(expired_tok, ensure_ascii=False))
        opener.return_value = token_file
        opener.return_value.__enter__ = mock.Mock(return_value=token_file)
        opener.return_value.__exit__ = mock.Mock(return_value=False)

        spot = _make_implicitgrantauth(scope, path)
        cached_tok = spot.validate_token(spot.cache_handler.get_cached_token())

        is_token_expired.assert_called_with(expired_tok)
        opener.assert_any_call(path, encoding='utf-8')
        self.assertIsNone(cached_tok)
Test that an expired token returns None.
tests/unit/test_oauth.py