<s> import pytest <EOL> try : <EOL> from unittest import mock <EOL> except ImportError : <EOL> import mock <EOL> @ pytest . fixture <EOL> def app ( tmpdir ) : <EOL> from flask import Flask <EOL> root_path = tmpdir . ensure ( "<STR_LIT>" , dir = True ) <EOL> tmpdir . ensure ( "<STR_LIT>" , dir = True ) <EOL> p = tmpdir . join ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> p . write ( "<STR_LIT>" ) <EOL> app = Flask ( __name__ ) <EOL> app . root_path = root_path . strpath <EOL> return app <EOL> def test_cake_init ( app ) : <EOL> from flask_cake import Cake <EOL> cake = Cake ( app ) <EOL> assert cake . app == app <EOL> assert cake . tasks == [ "<STR_LIT>" ] <EOL> assert cake . cake_parent == "<STR_LIT>" <EOL> def test_watchdog ( app , tmpdir ) : <EOL> from flask_cake import Cake <EOL> with mock . patch ( "<STR_LIT>" ) as mock_schedule : <EOL> Cake ( app ) <EOL> cake_dir = tmpdir . join ( "<STR_LIT>" ) . strpath <EOL> mock_schedule . assert_called_once_with ( mock . ANY , path = cake_dir , recursive = True ) <EOL> def test_events_on_any_event ( app ) : <EOL> from flask_cake . cake import Events <EOL> e = Events ( app . root_path , tasks = [ "<STR_LIT>" ] ) <EOL> with mock . patch ( "<STR_LIT>" ) as subprocess : <EOL> e . on_any_event ( None ) <EOL> subprocess . Popen . assert_called_once_with ( [ "<STR_LIT>" , "<STR_LIT>" ] , cwd = app . root_path , stdout = mock . ANY ) <EOL> def test_events_on_any_event_str ( app ) : <EOL> from flask_cake . cake import Events <EOL> e = Events ( app . root_path , tasks = "<STR_LIT>" ) <EOL> with mock . patch ( "<STR_LIT>" ) as subprocess : <EOL> e . on_any_event ( None ) <EOL> subprocess . Popen . assert_called_once_with ( [ "<STR_LIT>" , "<STR_LIT>" ] , cwd = app . root_path , stdout = mock . ANY ) </s>
