def test_greet_six(self, mock_dt, mock_logger): mock_dt.now.return_value = 23 obj = greeter.Greeter() name = "pony" test_str = "Good night, pony" mock_logger.warn(test_str) mock_logger.warn.assert_called_with(obj.greet_time(name)) self.assertEqual(obj.greet_time(name), test_str)
def jeeves(): jeeves = greeter.Greeter() yield jeeves # Clean up any mock data files created by the tests. if jeeves.outputs is not None: for file in jeeves.files: try: os.remove(file) except: pass
def __init__(self, master, controller): """Creates MirrorDisplay frame and places all plugin frames inside. Args: master: parent of this frame, usually direct container. controller: main window class providing public functions for control of the application from this frame's level. """ tk.Frame.__init__(self, master, width=1080, height=2560, cursor='none', bg='black') self._controller = controller # Binding keyboard event to application's main window. controller.bind('<Tab>', self._edit_mode) self._framename_coords_dict = controller.get_framename_coords_dict() self._window_in_edit_mode = False # Initializing frames passing self as a master and controller # into the init functions. self._clock = clock.Clock(self, controller) self._weather = weather.Weather(self, controller) self._greeter = greeter.Greeter(self, controller) self._smartcalendar = smartcalendar.Calendar(self, controller) # Placing frames on the main frame using place geometry # manager (module's frames should be placed only with place # manager). self._place_frames() # Setting keyboard focus so we can use keyboard bindings # without clicking on the window first. self.focus_set()
def onReady(self): try: self.options = Soph.defaultOpts with open("options.json", "r", encoding="utf-8") as f: opts = json.loads(f.read(), encoding="utf-8") self.options.update(opts) except Exception as e: self.log("Crap: {0}".format(e)) return self.greeting = self.options.get("greeting", "I'm ready") self.optTime = time.time() self.loadUsers() self.loadAliases() self.loadTz() task = self.loadAllUsers() fut = asyncio.ensure_future(task) async def check_deps(): try: resp = await wsClient.call(8888, "ping", "") print("index already up") except: print("index isn't up") kwargs = {} #if platform.system() == 'Windows': # from msdn [1] #CREATE_NEW_PROCESS_GROUP = 0x00000200 # note: could get it from subprocess #DETACHED_PROCESS = 0x00000008 # 0x8 | 0x200 == 0x208 #kwargs.update(creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP) sp = subprocess.Popen(["python", "indexBundle.py"], start_new_session=True, shell=True, stdin=None, stdout=None, stderr=None, close_fds=True, **kwargs) self.childProcs.append(sp) task = check_deps() fut = asyncio.ensure_future(task) self.addressPat = re.compile(r"^(Ok|So)((,\s*)|(\s+))" + self.options["name"] + r"\s*[,-\.:]\s*") for server in self.client.servers or {}: self.serverMap[server.name] = server.id if "servers" in self.options: for server_opts in self.options["servers"]: try: id = server_opts["id"] except: name = server_opts.get("name") id = self.serverMap[name] self.serverOpts[id] = server_opts for k, o in self.serverOpts.items(): regs = o.get("infoRegs", []) o["infoRegs"] = [re.compile(r) for r in regs] self.reactor = reactor.Reactor(self.serverOpts) self.greeters = utils.SophDefaultDict(lambda x: greeter.Greeter( self.serverOpts.get(x, {}).get("greetings", []))) self.ready = True
#import datetime #print(datetime.date.today()) #1/3 and 7/9 do the same from datetime import date print(date.today()) import greeter en_greeter = greeter.Greeter() en_greeter.greet("class")
def main(): greet = greeter.Greeter("Wesley") insult = insult_comic.InsultComic("Wesley") greet.speak() insult.speak()
def test_greet(self): test_str = "Hello, pony" name = "pony" obj = greeter.Greeter() self.assertEqual(obj.greet(name), test_str)
def test_greet_third(self): test_str = "Hello, pony" enter = "pony" obj = greeter.Greeter() self.assertEqual(obj.greet(enter), test_str)