Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sublime
- import sys
- from unittest import TestCase
- class TestNegateSentence(TestCase):
- def setUp(self):
- self.view = sublime.active_window().new_file()
- # make sure we have a window to work with
- s = sublime.load_settings("Preferences.sublime-settings")
- s.set("close_windows_when_empty", False)
- def tearDown(self):
- if self.view:
- self.view.set_scratch(True)
- self.view.window().focus_view(self.view)
- self.view.window().run_command("close_file")
- def test_negate_is(self):
- self.check_substitution('"The dog is black"', '"The dog is not black"')
- def check_substitution(self, input, expected):
- self.set_text(input)
- self.view.run_command("negate_sentence")
- self.assertEqual(self.get_text(), expected)
- def set_text(self, string):
- self.view.run_command("insert", {"characters": string})
- def get_text(self):
- return self.view.substr(self.view.line(self.view.text_point(0, 0)))
- def move_cursor(self, position):
- pt = self.view.text_point(0, position)
- self.view.sel().clear()
- self.view.sel().add(sublime.Region(pt))
Add Comment
Please, Sign In to add comment