Guest User

Untitled

a guest
Oct 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import sublime
  2. import sys
  3. from unittest import TestCase
  4.  
  5. class TestNegateSentence(TestCase):
  6. def setUp(self):
  7. self.view = sublime.active_window().new_file()
  8. # make sure we have a window to work with
  9. s = sublime.load_settings("Preferences.sublime-settings")
  10. s.set("close_windows_when_empty", False)
  11.  
  12. def tearDown(self):
  13. if self.view:
  14. self.view.set_scratch(True)
  15. self.view.window().focus_view(self.view)
  16. self.view.window().run_command("close_file")
  17.  
  18. def test_negate_is(self):
  19. self.check_substitution('"The dog is black"', '"The dog is not black"')
  20.  
  21. def check_substitution(self, input, expected):
  22. self.set_text(input)
  23. self.view.run_command("negate_sentence")
  24. self.assertEqual(self.get_text(), expected)
  25.  
  26.  
  27. def set_text(self, string):
  28. self.view.run_command("insert", {"characters": string})
  29.  
  30. def get_text(self):
  31. return self.view.substr(self.view.line(self.view.text_point(0, 0)))
  32.  
  33. def move_cursor(self, position):
  34. pt = self.view.text_point(0, position)
  35.  
  36. self.view.sel().clear()
  37. self.view.sel().add(sublime.Region(pt))
Add Comment
Please, Sign In to add comment