Giter VIP home page Giter VIP logo

diveintopython3's Introduction

Dive Into Python3 の章立てに沿った問題と問題への回答を検証するためのunittest

必要な物意する

githubでforkする

forkしたものを適当な場所にcloneする

環境設定の仕方

python3.3をインストール済みであること.

setup.shを用いて

% ./setup.sh

とするとpyvenvで仮想環境が作られ、その環境の中に packaging toolであるdistributeとpipがインストールされる.

仮想環境を起動する

% source py3.3/bin/activate

起動するとprompが変わる。

仮想環境にpipを使って依存しているpackageを入れる

(py3.3) % pip install -r freeze.txt

これでcheck.pyに必要なものがインストールされる。

仮想環境を終了する

(py3.3) % deactivate

check.pyの使い方

(py3.3) python check.py exercises/chap2/q0002.py

とすると、標準出力にいろいろメッセージが出る.

前半は循環複雑度を測定した結果である. 課題の複雑さからすると5以上は好ましくない.

後半はpep8のチェックである(pep8.pyを使用)

testの行い方

(py3.3) python -m tests.chap2.q0002

とすると、exercises/chap2/q0002.py がunittestされる. 結果が標準出力にでるので、全てokであること

testの実装が間違っていると思われる場合はissueをたててください.

Enjoy!

diveintopython3's People

Contributors

bgnori avatar kannokanno avatar

Watchers

 avatar James Cloos avatar

Forkers

bgnori

diveintopython3's Issues

chap3.q0005の test_15 ケースが通らない

テスト内にて得ようとしているリストの長さが違っているように見えます。

    def test_15(self):
        xs = q0005.foo(15)
        self.assertEqual(15, len(xs))
        self.assertEqual('Fizz Buzz', xs[15])

とありますが、下記の実装

5) Fizz Buzzのリストxsを内包表記を用いてつくる関数foo(n)を実装せよ. 0 < n
  xs[1] = 1, xs[2] = 2, xs[3] ='Fizz', ... xs[15] = 'Fizz Buzz' ... xs[n] = ??? などとなる.

また他のテストパターンに従うと、期待される出力は

>>> xs = q0005.foo(15)
>>> len(xs)
16

ではないでしょうか。

chap3.q0007, q0008 の test_docstring テストケースが通らない

恐らくテスト対象として参照している関数が違っています。
テストファイル内で

    def test_docstring(self):
        self.assertIsNotNone(q0007.foo.__doc__)

    def test_zero(self):
        self.assertEqual({}, q0007.circular(0))

上記のようになっており、関数名はcircularで実装を行うため
fooの部分がcircularかと思われます。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.