добавлен кодинг на занятии 23 тест метода target

This commit is contained in:
ehermakov 2024-06-09 21:16:47 +03:00
parent dd539555b9
commit 5e0cf283d6
9 changed files with 55 additions and 16 deletions

View File

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project> </project>

View File

@ -4,10 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b389cdea-22f5-4ba2-8b46-337091984b3c" name="Changes" comment="код по 22 части урока"> <list default="true" id="b389cdea-22f5-4ba2-8b46-337091984b3c" name="Changes" comment="код по 22 части урока" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ShipField.py" beforeDir="false" afterPath="$PROJECT_DIR$/ShipField.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -37,20 +34,21 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;Python.ShipField.executor&quot;: &quot;Run&quot;, "Python.ShipField.executor": "Run",
&quot;Python.main (1).executor&quot;: &quot;Run&quot;, "Python.main (1).executor": "Run",
&quot;Python.main.executor&quot;: &quot;Debug&quot;, "Python.main.executor": "Debug",
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;git-widget-placeholder&quot;: &quot;main&quot;, "git-widget-placeholder": "main",
&quot;last_opened_file_path&quot;: &quot;Y:/Downloads/временный гит/hnc-eduard/HNS/Excercises/ShipCraft/Переделка&quot; "last_opened_file_path": "C:/Users/Eduardo/Documents/Программирование с Артуром/HNS/hnc-eduard/HNS/Excercises/ShipCraft"
} }
}</component> }]]></component>
<component name="RunManager" selected="Python.main"> <component name="RunManager" selected="Python.main">
<configuration name="ShipField" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="ShipField" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Переделка" /> <module name="Переделка" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs> <envs>
@ -72,6 +70,7 @@
</configuration> </configuration>
<configuration name="ShipView" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="ShipView" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Переделка" /> <module name="Переделка" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs> <envs>
@ -93,6 +92,7 @@
</configuration> </configuration>
<configuration name="main (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="main (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Переделка" /> <module name="Переделка" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs> <envs>
@ -114,6 +114,7 @@
</configuration> </configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Переделка" /> <module name="Переделка" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs> <envs>
@ -169,7 +170,7 @@
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url> <url>file://$PROJECT_DIR$/main.py</url>
<line>136</line> <line>133</line>
<option name="timeStamp" value="1" /> <option name="timeStamp" value="1" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>

View File

@ -58,7 +58,42 @@ class TestShipField(TestCase):
def test_action(self): def test_action(self):
self.fail() self.fail()
def test_target(self): def test_target_ShipMode_PUT(self):
ship_field = ShipField()
ship_field.set_ship_size(3)
ship_field.set_ship_direction(ShipDirection.HORIZONTAL)
index = 5 * ship_field.field_size + 5
old_field_string = str.join(' ', ship_field.field)
ship_field.target(5, 5)
field_after_target = [ship_field.field[index], ship_field.field[index + 1], ship_field.field[index + 2]]
ship_field.field[index] = ' '
ship_field.field[index + 1] = ' '
ship_field.field[index + 2] = ' '
new_field_string = str.join(' ', ship_field.field)
self.assertListEqual(['p', 'p', 'p'], field_after_target)
self.assertNotIn('p', new_field_string)
self.assertEqual(new_field_string, old_field_string)
def test_target_ShipMode_SHOOT(self):
ship_field = ShipField()
ship_field.toggle_field_mode()
index = 5 * ship_field.field_size + 5
old_field_string = str.join(' ', ship_field.field)
ship_field.target(5, 5)
field_after_target = ship_field.field[index]
ship_field.field[index] = ship_field.field[index].replace('+', '')
new_field_string = str.join(' ', ship_field.field)
self.assertIn('+', field_after_target)
self.assertNotIn('+', new_field_string)
self.assertEqual(new_field_string, old_field_string)
def get_ship(self):
self.fail() self.fail()
def test_clear_marker(self): def test_clear_marker(self):