Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6775869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:57:30+00:00 2026-05-26T15:57:30+00:00

I am about to make a game using python and libtcod roguelike game library.

  • 0

I am about to make a game using python and libtcod roguelike game library.

More to the point, I am using PyMock because I am just starting to learn Test-Driven Development, and I am determined not to cheat. I really want to get into the habit of doing it properly, and according to TDD I need a failing unit test before I write my first line of code.

I figure my first test of my “production” code should be that its dependency, libcotdpy, is imported.

My testing file:

#!/usr/bin/python
import pymock   # for mocking and unit testing
import game     # my (empty) production code file, game.py

class InitializeTest(pymock.PyMockTestCase):
    def test_libtcod_is_imported(self):
        # How do I test that my production file imports the libtcodpy module?

if __name__=="__main__":
    import unittest
    unittest.main()

Please:

1) (python people) How do I test that the module is loaded?

2) (TDD people) Should I be unit testing something this basic? If not, what is the first thing I should be testing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:57:31+00:00Added an answer on May 26, 2026 at 3:57 pm

    1) 'your_module' in sys.modules.
    Don’t actually use that, though:

    2)
    What should your library should do?
    Is it “have a dependency on libcotdpy”? I think not.

    You’ve just made a design choice that wasn’t test-driven!

    Write a test that demonstrates how you want to use the library. Don’t think about how you’re going to implement it. For example:

    player = my_lib.PlayerCharacter()
    assert player.position == (0, 0)  # or whatever assert syntax `pymock` uses
    press_key('k')
    assert player.position == (0, 1)
    

    Or something similar. (I don’t know what you want your library to do, or how much libtcod provides.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am about to start to make the interface for a game in WPF
I'm just about to make my first trip into the world of JNI (Java
We're about to make data transformation from one system to another using SSIS. We
I'm trying to make this 2-player web game application using Spring MVC. I have
I am attempting to make a game using java, and I need a plugin
I am going to make platformer game on Flash using starling framework. I wont
I have a couple of Python functions that I use to make game development
I'm using OpenGL ES to make a game on the iPhone. Unfortunately, I see
I am trying to make a simple text-based game in Python. The idea of
I'm currently trying to learn more about object oriented design in C++ (familiar with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.