Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!
# the functions to be tested: class Library: def __init__(self, fn): pass self.fn = fn self.shelf = shelve.open(fn) def add_Player(self, team): pass self.shelf[team] = team def add_Score(self, team): pass self.shelf[team.scores] = team def close(self): pass self.shelf.close() class Player: def __init__(self, team, scores): self.team, self.scores = team, scores def __eq__(self, other): if type(other) is type(self): return self.__dict__ == other.__dict__ return False def __ne__(self, other): return not self.__eq__(other)
class Players: def __init__(self, shelf, player, score_input, score): self.shelf = shelve.open('shelf_scores.shlf') self.player = player self.score_input = score_input self.score = score def add_player(self, shelf): while True: msg = 'Add a player: ' player = raw_input(msg).strip() if player: score = 0 while True: msg = 'Add a score for ' + player + ': ' score_input = raw_input(msg).strip() if score_input.isdigit(): if int(score_input) > int(score): print score_input, '>', score, ', new high score:', score_input shelf[player] = score_input score = score_input else: print score_input, '<', score, ', pass' else: print "Score empty or not recognized, exiting player", player break else: print 'No player, exiting' break Players.read_scores(self, shelf) def read_scores(self, shelf): for player in sorted(shelf.keys()): print 'Player', player, 'high score:', shelf[player] shelf.close() if __name__ == "__main__": shelf = shelve.open('shelf_scores.shlf') player = 'Anonymous' score_input = 0 score = 0 instance = Players(shelf, player, score_input, score) Players.add_player(instance, shelf) shelf.close()
# the unittest: class TestScores(unittest.TestCase): def setUp(self): self.game_fn = 'shelf_scores.shlf' self.team = players2.Library('Joe', 'Sally','Jim') self.scores = players2.Player(10, 20, 30) self.game = players2.Player(self.game_fn, self.team, self.scores) self.game.add_Player(self.team) self.game.add_Score(self.scores) def test_add_Player(self): observed = self.game.add_Player(self.team) self.assertEquals(observed, self.team) def test_add_Score(self): observed = self.game.add_Score(self.team) self.assertEquals(observed, self.team) def tearDown(self): self.game.close() if __name__ == "__main__": unittest.main()
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Why does my ISP's DNS resolve a non-existent domain as localhost ?||10||49|
|Internal users cannot browse external corporate website||4||30|
|How to repair a corrupt windows domain user account||3||45|