-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split out utilities from ob.py to ob_util.py
- Loading branch information
assaf
committed
Jun 21, 2017
1 parent
7eb7294
commit a66e523
Showing
6 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
||
import ob | ||
import ob_util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def nth_planet_of_star(star, n): | ||
return n * 65536 + star | ||
|
||
def generate_planets(star): | ||
planet_index = 1 | ||
while planet_index < 65536: | ||
yield nth_planet_of_star(star, planet_index) | ||
planet_index += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
|
||
from .context import ob_util | ||
|
||
class ObUtilTest(unittest.TestCase): | ||
def test_generate_planets(self): | ||
planets = ob_util.generate_planets(0x100) | ||
self.assertEquals(planets.next(), 0x10100) | ||
self.assertEquals(planets.next(), 0x20100) | ||
|
||
planets = ob_util.generate_planets(0x4141) | ||
self.assertEquals(planets.next(), 0x14141) | ||
self.assertEquals(planets.next(), 0x24141) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters