Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LT「データまえしょりすとのためのpytest入門」@みんなのPython勉強会#46

komo_fr
June 12, 2019

 LT「データまえしょりすとのためのpytest入門」@みんなのPython勉強会#46

komo_fr

June 12, 2019
Tweet

More Decks by komo_fr

Other Decks in Technology

Transcript

  1. σʔλ·͑͠ΐΓ͢ͱͷ
    QZUFTUೖ໳
    %BUF
    &WFOUΈΜͳͷ1ZUIPOษڧձ

    IUUQTTUBSUQZUIPODPOOQBTTDPNFWFOU

    4QFBLFS!LPNP@GS 5PNPLP'VSVLJ

    View full-size slide

  2. w!LPNP@GS 5PNPLP'VSVLJ

    w ͓͠͝ͱ
    w ҩྍը૾৘ใγεςϜͷ։ൃʢઃܭ࣮૷ʣ
    w ‎1ZUIPOͰσʔλ׆༻ͷ1P$࡞੒
    w ‎ϑϦʔ
    w ͨ·ʹ1ZUIPOຊͷϨϏϡʔΛ΍ͬͯΔ
    w ʰ1ZUIPOʹΑΔ͋ͨΒ͍͠σʔλ෼ੳͷڭՊॻʱᠳӭࣾ
    w ʰͰ͖Δ࢓ࣄ͕͸͔ͲΔ1ZUIPOࣗಈॲཧશ෦ೖΓɻʱΠϯϓϨε
    !2
    8IPBN*

    View full-size slide

  3. ςετࣗಈԽܦݧ͋Μ·Γͳ͍
    σʔλલॲཧ԰͕
    ʰςετۦಈ1ZUIPOʱΛಡΜͰ

    QZUFTUೖ໳͢Δ·Ͱͷաఔ
    ࠓ೔࿩͢͜ͱ

    View full-size slide

  4. w ʮ͜ͷσʔλΛ࢖ͬͯ˓̋ͳ͜ͱ͕Ͱ͖ͳ͍͔ʯͱ

    ະ੔උͷੜσʔλΛ௖͘
    w +VQZUFS/PUFCPPL্ͰQBOEBT౳Ͱσʔλ֬ೝ

    ΰϦΰϦલॲཧ
    w ͱͯ΋టष͍ॲཧௐࠪ
    w ͜͜Ͱॻ͘ίʔυ͸ॻ͖ࣺͯʹͳΔ͜ͱ͕ଟ͍
    w ʮΠΠͶʂʯͱͳͬͨΒɺ࣍ͷεςοϓʹਐΉ
    !4
    ͓࢓ࣄͷྲྀΕ౰࣌ͷ೰Έ

    View full-size slide

  5. w ʮ͜ͷσʔλΛ࢖ͬͯ˓̋ͳ͜ͱ͕Ͱ͖ͳ͍͔ʯͱ

    ະ੔උͷੜσʔλΛ௖͘
    w +VQZUFS/PUFCPPL্ͰQBOEBT౳Ͱσʔλ֬ೝ

    ΰϦΰϦલॲཧ
    w ͱͯ΋టष͍ॲཧௐࠪ
    w ͜͜Ͱॻ͘ίʔυ͸ॻ͖ࣺͯʹͳΔ͜ͱ͕ଟ͍
    w ʮΠΠͶʂʯͱͳͬͨΒɺ࣍ͷεςοϓʹਐΉ
    !5
    ͓࢓ࣄͷྲྀΕ౰࣌ͷ೰Έ
    ͜ͷ࣌఺Ͱ͸ɺ
    ͜ͷίʔυ͕࠶ͼ
    ࢖ΘΕΔ͔Ͳ͏͔͸Θ͔Βͳ͍ʜʜ

    View full-size slide

  6. w ʮ͜ͷσʔλΛ࢖ͬͯ˓̋ͳ͜ͱ͕Ͱ͖ͳ͍͔ʯͱ

    ະ੔උͷੜσʔλΛ௖͘
    w +VQZUFS/PUFCPPL্ͰQBOEBT౳Ͱσʔλ֬ೝ

    ΰϦΰϦલॲཧ
    w ͱͯ΋టष͍ॲཧௐࠪ
    w ͜͜Ͱॻ͘ίʔυ͸ॻ͖ࣺͯʹͳΔ͜ͱ͕ଟ͍
    w ʮΠΠͶʂʯͱͳͬͨΒɺ࣍ͷεςοϓʹਐΉ
    !6
    ͓࢓ࣄͷྲྀΕ౰࣌ͷ೰Έ

    View full-size slide

  7. w ʮ͜ͷσʔλΛ࢖ͬͯ˓̋ͳ͜ͱ͕Ͱ͖ͳ͍͔ʯͱ

    ະ੔උͷੜσʔλΛ௖͘
    w +VQZUFS/PUFCPPL্ͰQBOEBT౳Ͱσʔλ֬ೝ

    ΰϦΰϦલॲཧ
    w ͱͯ΋టष͍ॲཧௐࠪ
    w ͜͜Ͱॻ͘ίʔυ͸ॻ͖ࣺͯʹͳΔ͜ͱ͕ଟ͍
    w ʮΠΠͶʂʯͱͳͬͨΒɺ࣍ͷεςοϓʹਐΉ
    !7
    ͓࢓ࣄͷྲྀΕ౰࣌ͷ೰Έ
    ࣗ෼͕ॻ͍ͨΫιίʔυͷ
    मਖ਼ɾϦϑΝΫλϦϯάɾ෦඼Խ

    View full-size slide

  8. w ʮ͜ͷσʔλΛ࢖ͬͯ˓̋ͳ͜ͱ͕Ͱ͖ͳ͍͔ʯͱ

    ະ੔උͷੜσʔλΛ௖͘
    w +VQZUFS/PUFCPPL্ͰQBOEBT౳Ͱσʔλ֬ೝ

    ΰϦΰϦલॲཧ
    w ͱͯ΋టष͍ॲཧௐࠪ
    w ͜͜Ͱॻ͘ίʔυ͸ॻ͖ࣺͯʹͳΔ͜ͱ͕ଟ͍
    w ʮΠΠͶʂʯͱͳͬͨΒɺ࣍ͷεςοϓʹਐΉ
    !8
    ͓࢓ࣄͷྲྀΕ౰࣌ͷ೰Έ
    ੜσʔλͷόϦΤʔγϣϯ૿
    ʢલॲཧͷόϦΤʔγϣϯ૿ʣ
    ࣗ෼͕ॻ͍ͨΫιίʔυͷ
    मਖ਼ɾϦϑΝΫλϦϯάɾ෦඼Խ

    View full-size slide

  9. w ʮ͜ͷσʔλΛ࢖ͬͯ˓̋ͳ͜ͱ͕Ͱ͖ͳ͍͔ʯͱ

    ະ੔උͷੜσʔλΛ௖͘
    w +VQZUFS/PUFCPPL্ͰQBOEBT౳Ͱσʔλ֬ೝ

    ΰϦΰϦલॲཧ
    w ͱͯ΋టष͍ॲཧௐࠪ
    w ͜͜Ͱॻ͘ίʔυ͸ॻ͖ࣺͯʹͳΔ͜ͱ͕ଟ͍
    w ʮΠΠͶʂʯͱͳͬͨΒɺ࣍ͷεςοϓʹਐΉ
    !9
    ͓࢓ࣄͷྲྀΕ౰࣌ͷ೰Έ
    ੜσʔλͷόϦΤʔγϣϯ૿
    ʢલॲཧͷόϦΤʔγϣϯ૿ʣ
    ࣗ෼͕ॻ͍ͨΫιίʔυͷ
    मਖ਼ɾϦϑΝΫλϦϯάɾ෦඼Խ

    View full-size slide

  10. w ౰࣌ͷࢲͷςετίʔυΛॻ͘εΩϧ
    w Ҏલ։ൃʹ͸͍͕ͨɺςετࣗಈԽ͞Ε͍ͯͳ͍؀ڥͩͬͨ
    w ʢؾ͕ڰ͍ͦ͏ͩͬͨʣ
    w ݸਓͰ044ʹػೳ௥ՃͷQVMMSFRVFTUΛૹΔͱ͖ʹɺ

    ඞཁʹഭΒΕͯςετίʔυΛॻ͍ͨ͜ͱ͸͋Δ QZUFTU

    w ͨͩ͠ɺ೔ৗతʹॻ͚͍ͯΔΘ͚Ͱ͸ͳ͍
    !10
    ςετίʔυΛॻ͍ͯਫ਼ਆͷۉߧΛอ͍ͪͨ

    View full-size slide

  11. ؾ͕ڰ͍ͦ͏ͳ
    టष͍લॲཧͷ܁Γฦ͠Λɺ
    ςετࣗಈԽͰ
    গ͠Ͱ΋ָʹ͍ͨ͠ʜ

    View full-size slide

  12. ςετࣗಈԽ
    ಋೖͷ͖͔͚ͬ
    !12

    View full-size slide

  13. w ςετͷೖ໳ʹ޲͍͍ͯΔʢͱࢥ͏ʣίʔυ
    w ग़ྗ͕໌֬ͰɺԿճ΋मਖ਼͢Δػձ͕͋Δίʔυ
    w ࢲͷ৔߹
    w ϩʔΧϧʹ͋ΔIUNMϑΝΠϧ͔ΒσʔλΛநग़ͯ͠ɺ

    DTWܗࣜʹม׵͢Δࣗ࡞લॲཧπʔϧ
    w ग़ྗ͕໌֬ͳͷͰɺςετΛॻ͖΍͍͢
    w ೖྗ͸ɺͨ·ʹ૝ఆ͠ͳ͍ܗࣜͷIUNM͕དྷΔ
    w ‎मਖ਼ͷػձ͕Կճ΋ൃੜ͢Δ
    !13
    ͖͔͚ͬͪΐ͏Ͳྑ͍୊ࡐ͕͋ͬͨ

    View full-size slide

  14. w +VQZUFS/PUFCPPLͰॻ͖ԥΔɺճ͖ͬ͜Γͷίʔυ
    w ػցֶशϞσϧ΍ɺ

    ग़ྗ஋͕֬཰తͰৗʹಉ͡ͱ͸ݶΒͳ͍έʔε
    w ݸਓతʹ͸ॻ͘΂͖ͩͱࢥ͏͠ॻ͖͍͕ͨɺ

    ࠷ॳ͸γϯϓϧͳέʔεʹͨ͠ํ͕ྑ͍͔΋
    w ࢲ΋Α͘Θ͔ΒΜͷͰɺ

    ͜ͷลৄ͍͠ਓ͕͍ͨΒ࠙਌ձͰڭ͍͑ͯͩ͘͞
    !14
    ςετೖ໳ʹ޲͍͍ͯͳ͍ʢͱࢥ͏ʣίʔυ

    View full-size slide

  15. w σʔλαΠΤϯεܥͷఆ൪044Ͱ࠾༻͞Ε͍ͯͨ
    w OVNQZ QBOEBT NBUQMPUMJCʜʜ
    w ॻ͖ํʹࠔͬͨΒɺ͜ͷลͷίʔυΛࢀߟʹ͠Α͏ͱࢥͬͨ
    w ͪΐ͏Ͳʰςετۦಈ1ZUIPOʱ ᠳӭࣾ
    ͕

    ൃച͞ΕͨλΠϛϯάͩͬͨ
    !15
    ԿͷπʔϧΛ࢖͏͔‎QZUFTUΛબ୒
    ը૾ɿ
    IUUQTXXXTIPFJTIBDPKQCPPLEFUBJM

    View full-size slide

  16. w ʢݸਓతʹ͸ʣຊͷ಺༰Λ׬ᘳཧղͯ͠ɺ

    ͍͖ͳΓϕετϓϥΫςΟΫεΛ΍Ζ͏ͱͯ͠΋ଓ͔ͳ͍
    w ຊͰ঺հ͞Ε͍ͯΔશ͕ͯɺࣗ෼ͷέʔεͰඞཁͱ͸ݶΒͳ͍
    w ि໨ɿେࡶ೺ʹಡΜͰ֓ཁΛ೺Ѳ͠ɺ·ͣ͸ࡶʹ࢝ΊΔ
    w ि໨ɿࡶͰ΋͍͍͔Βɺܧଓͯ͠ఆணͤ͞Δ
    w ि໨ʙɿඞཁʹԠͯ͡ɺຊ΍ެࣜυΩϡϝϯτΛݟָͯʹ͢Δ
    !16
    ಋೖͷํ਑

    View full-size slide

  17. w ͩΒͩΒJOQVUʹภΒͳ͍Α͏ʹɺ୹ظ໨ඪΛܾΊΔ
    w ʰ࣮຿Ͱॻ͍͍ͯΔίʔυʹରͯ͠ɺԿͰ΋ྑ͍͔ΒͭҎ্ͷؔ਺ʹςε
    τίʔυΛ௥Ճ͢Δʢ༵ۚ೔·Ͱʣʱ
    w ݄ʙ໦ͷؒʹʰςετۦಈ1ZUIPOʱશମΛ௨ಡ͢Δ
    w ֓ཁΛ೺Ѳ͢Δͷ͕໨త
    w ೔͋ͨΓେମʙ࣌ؒ͘Β͍
    w ࣌ؒͷ౎߹্શͯͷจষΛ͔ͬ͠ΓಡΉ͜ͱ͸Ͱ͖ͳ͍
    w ͨͩ͠ɺίϚϯυ͸࣮ࡍʹଧͬͯࢼͨ͠
    w "QQFOEJYͷ֦ுػೳʹؔ͢ΔτϐοΫ΋ɺ࠷ॳ͸ඈ͹ͨ͠
    !17
    ि໨ ֓ཁΛ೺Ѳͯ͠ɺ·ͣ͸ࡶʹ࢝ΊΔʣ

    View full-size slide

  18. w ςετ͠΍͍͢෦෼Λத৺ʹɺςετίʔυΛॻ͍͍ͯ͘
    w IUNMQBOEBTͷ%BUB'SBNFͷม׵෦෼
    w ࡶɺͱ͸
    w UNQEJSͱ͔࢖ΘͣʹɺςετͰग़ྗ͞ΕͨϑΝΠϧ͸खಈͰফ͢
    w ྫ֎ॲཧ෦෼ͷςετ͸ͱΓ͋͑ͣޙճ͠౳
    w ֦ுػೳΛೖΕΔ
    w QZUFTUqBLF
    w QZUFTUDPW
    !18
    ि໨ ࡶͰ΋͍͍͔Βɺܧଓͯ͠ఆணͤ͞Δʣ

    View full-size slide

  19. w ߦ΍ྻͷฒͼ·ͰݫີʹνΣοΫ͍ͨ͠έʔεɺ

    ཁૉͷ஋͑͞߹͍ͬͯΕ͹ྑ͍έʔεɺ৭ʑʜʜ
    w QBOEBTUFTUJOHϞδϡʔϧ
    w BTTFSU@GSBNF@FRVBM

    w BTTFSU@TFSJFT@FRVBM

    w QBOEBTͷςετίʔυࣗମ͕αϯϓϧͱͯ͠ࢀߟʹͳΔ
    !19
    QBOEBTͷ%BUB'SBNFΛͲ͏ൺֱ͢Δʁ
    5FTUJOH'VODUJPOɿ
    IUUQTQBOEBTQZEBUBPSHQBOEBTEPDTTUBCMFSFGFSFODF
    HFOFSBM@VUJMJUZ@GVODUJPOTIUNMUFTUJOHGVODUJPOT

    View full-size slide

  20. w ஈʑςετίʔυ͕૿͖͑ͯͯɺࢧো͕ग़ͯ͘Δ
    w ςετաఔͰੜͨ͡ϑΝΠϧΛUNQEJSͰࣗಈͰফ͢
    w ϑΟΫενϟ࢖ͬͯΈΔ
    w ෦෼తʹςετ࣮ߦ͢Δ
    w ͳͲͳͲʜ
    w ʰςετۦಈQZUIPOʱΛࡧҾతʹ࢖͍ͳ͕Βಋೖ
    w Χόʔ͍ͯ͠ͳ͍෦෼͸ެࣜυΩϡϝϯτΛࢀর
    !20
    ि໨ʙʢඞཁʹԠͯ͡ɺָʹ͢Δʣ

    View full-size slide

  21. w ྫ֎ॲཧ෦෼ʹ΋ςετΛೖΕΔ
    w ૝ఆέʔε
    w େྔͷσʔλΛॲཧ͢ΔதͰɺ૝ఆ͍ͯ͠ͳ͍ϑΥʔϚοτͷσʔ
    λ͕དྷͨ৔߹͸ɺྫ֎Λൃੜͤͯ͞ϩάΛग़͠ɺ࢒Γͷσʔλͷ
    ॲཧΛଓ͚͍ͨ
    w ࢭ·ͬͯཉ͘͠ͳ͍͕ɺϩά͸͔ͬ͠Γग़ͯ͠΄͍͠
    w ςετ͍ͨ͜͠ͱɿ
    w ظ଴௨Γྫ֎͕ൃੜ͢Δ͔ QZUFTUSBJTF

    w FYDFQU۟ͷத਎͕ظ଴௨Γಈ͍͍ͯΔ͔ NPDL

    !21
    ि໨ʙʢඞཁʹԠͯ͡ɺָʹ͢Δʣ

    View full-size slide

  22. w ਫ਼ਆͷ҆ఆ͕൒୺ͳ͍
    w ίʔυ͕͓͔͍͠ͷ͔ɺҙਤ͠ͳ͍σʔλܗ͕ࣜདྷͨͷ͔੾Γ෼
    ͚΍͍͢
    w ϦϑΝΫλϦϯά࣌ͷ҆৺ײ
    w ޙͰ࢖͏࣌ɺςετίʔυ͕࢓༷୅ΘΓʹͳΔ
    w టष͍લॲཧͷίʔυ͸ɺ࢓༷΋టष͘ͳΓ΍͍͢
    w ͨͩ௕ظӡ༻ͯ͠ͳ͍ͷͰɺ

    ௕ظӡ༻ͨ࣌͠ͷ໰୊͸·ͩΑ͘Θ͔Βͳ͍
    !22
    ΍ͬͯΈͨॴײ

    View full-size slide

  23. ͓·͚ͷ৘ใ
    !23

    View full-size slide

  24. w ʰ(FUUJOH4UBSUFE5FTUJOHJO%BUB4DJFODFʱ
    w 1Z$PO64ͷτʔΫ QZWJEFPPSHͰ؍ΕΔ

    w ςετʹ͓͚Δσʔλܥಛ༗ͷ໰୊ʹ৮Εͨޙɺ

    QZUFTUͷଞɺ)ZQPUIFTJTʹΑΔ%BUB'SBNFͷςετσʔλੜ
    ੒ͳͲͷ5JQTΛ঺հ͍ͯ͠Δɻ
    w εϥΠυ࠷ޙͷࢀߟจݙͰɺ

    աڈͷ1Z$POͷςετؔ܎ͷτʔΫ͕·ͱΊΒΕ͍ͯΔɻ
    !24
    σʔλܥͷͨΊͷςετࣗಈԽ৘ใ
    QZWJEFPɿ
    IUUQTQZWJEFPPSHQZDPOVTHFUUJOHTUBSUFEUFTUJOHJOEBUBTDJFODFIUNM
    TMJEF
    IUUQTTQFBLFSEFDLDPNQZDPOKFTGPSEHFUUJOHTUBSUFEUFTUJOHJOEBUBTDJFODF

    View full-size slide

  25. w σʔλલॲཧ͸టष͘ͳΓ͕ͪ
    w QZUFTUಋೖͰɺগ͠Ͱ΋ਫ਼ਆͷۉߧΛอͱ͏
    w 0VU͕໌֬ͳσʔλίϯόʔτπʔϧ͸ɺ

    ൺֱతςετͷೖ໳ʹ޲͍͍ͯΔʜʜͱࢥ͏
    w ·ͩงғؾͰ΍ͬͯΔͷͰɺ

    σʔλܥͷςετίʔυͷ࿩ʹৄ͍͠ํ͕͍ͨΒɺ

    ࠙਌ձͰڭ͍͑ͯͩ͘͞
    w ʰςετۦಈ1ZUIPOʱ͸ͱͯ΋ྑ͍ຊͰ͢
    !25
    ·ͱΊ

    View full-size slide

  26. Ұ෦ϨϏϡʔʹࢀՃ͠·ͨ͠

    View full-size slide

  27. 5IBOLZPVGPS
    MJTUFOJOH
    !27

    View full-size slide