# Testing channels using nose

**URL:** <https://forums.plex.tv/t/testing-channels-using-nose/31595>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [March 27, 2013, 9:32pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595 "2013-03-27T21:32:05Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [March 27, 2013, 9:32pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/1 "2013-03-27T21:32:05Z")

</div>

I’m working on getting Plex channels and nose working together. This can allow a much quicker workflow: run tests without the server running.  
  
[Documentation for Plex/nose Example](http://mikew.github.io/plex-nose-example/)  
[Source on GitHub](https://github.com/mikew/plex-nose-example)  
  
Read either of those, if you’d like. The repository also doubles as a functional starting point for Plex channels (read: plex plugin boilerplate)  
  
Since I am fairly new to Python and newer still to testing in Python, any insight you may have would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 6, 2013, 9:47am UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/2 "2013-04-06T09:47:24Z")

</div>

I’ve pushed some new features: a couple of new decorators to ensure the Dict is always reset and a TestCase to inherit from to save you from repeating the same decorators over and over.

```
import plex_nose
class SimpleTests(plex_nose.TestCase):
def test_dict_is_reset():
eq_({}, Dict._dict)
```
  
Is anyone using this? I’m adding what I can as I go, but my channel doesn’t use Data, SharedCode or anything other than Dict, really.

---

<div class="post-metadata">

**Author:** ![Gerk](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gerk/32/81980_2.png) [@Gerk](https://forums.plex.tv/u/Gerk)\
**Post date:** [April 6, 2013, 3:52pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/3 "2013-04-06T15:52:52Z")

</div>

I'm not using it (yet), haven't had the time to RTFM but in the future I'd like to start using this. &nbsp;

Maybe a very brief tutorial might be in order if you have the time/inclination to do so.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 6, 2013, 5:43pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/4 "2013-04-06T17:43:23Z")

</div>

I have been trying to keep its own [Contents/Code/test\_\_\_init\_\_.py](https://github.com/mikew/plex-nose-example/blob/master/Contents/Tests/test ___init__.py) as exemplary as possible, though I suppose I could write a “zero-to-testing” tutorial later when work is finished

---

<div class="post-metadata">

**Author:** ![Gerk](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gerk/32/81980_2.png) [@Gerk](https://forums.plex.tv/u/Gerk)\
**Post date:** [April 6, 2013, 6:00pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/5 "2013-04-06T18:00:21Z")

</div>

Yep a zero-to-testing example with a real-world example would probably be very useful (not only for myself but for others). &nbsp;Thanks for doing this!

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 7, 2013, 5:27pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/6 "2013-04-07T17:27:27Z")

</div>

So I could not get things running smoothly on Ubuntu.

- Plex ships its own python on Linux, so you cannot install nose via pip or easy\_install or apt  
- tests needed to be run under sudo for permission errors  
- the file to run the tests does not exit properly, so you’ve got to kill a python process before you can continue  
- tests pass or fail at random  
  
  
I’ll see if it will work on at least windows, but that’s really got me bummed out.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 8, 2013, 7:19am UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/7 "2013-04-08T07:19:38Z")

</div>

so windows was even less of a go, but I've got Ubuntu dialed in at least. and now running tests without guard is much easier via run-osx.sh or run-ubuntu.sh

still no concrete tutorial though, that will take some time.

---

<div class="post-metadata">

**Author:** ![Gerk](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/gerk/32/81980_2.png) [@Gerk](https://forums.plex.tv/u/Gerk)\
**Post date:** [April 8, 2013, 7:01pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/8 "2013-04-08T19:01:21Z")

</div>

Thanks again for continuing to work on this one. &nbsp;I think it will be incredibly useful for us channel devs going forward once it's up and running and we have a tutorial to point people towards.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 9, 2013, 8:12pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/9 "2013-04-09T20:12:25Z")

</div>

so I’ve just pushed a “tutorial” of sorts. the channel now streams videos from [Gamespot.com](http://Gamespot.com), complete with a URL service and using Services/Shared Code, everything is tested, and more importantly, it doesn’t actually hit the network during the tests.  
  
Now, I am awful at writing tutorials, but love answering questions. so if you have any, shoot.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 11, 2013, 2:06am UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/10 "2013-04-11T02:06:32Z")

</div>

after another round of integrating this with my plugin, I’ve added a few test helpers, spec so the output is nicer, and tried my best at [documenting everything in the README](https://github.com/mikew/plex-nose-example#writing-tests) (though I still recommend browsing Contents/Tests/)

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 11, 2013, 4:44am UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/11 "2013-04-11T04:44:34Z")

</div>

okay, last update for a while. first post is hella updated.  
  
I’ve also pushed [the current development branch of ss-plex](https://github.com/mikew/ss-plex.bundle/tree/tests/Contents/Tests), for a way more in-depth example.  
  
really, I cannot stress how easy this makes development. the suite in ss-plex finishes in just under 2s real time (~0.3s in python).  
  
and when it comes time to start hacking at something, just write a function in a file that gets tested (test\_\_\_init\_\_.py), code away as you would in your **init**.py (bonus: print is a useful statement to us now), and the tests get run each file save.  
  
either way, you get a meaningful response from your code before Plex Media Server would usually have it reloaded.

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [April 11, 2013, 4:05pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/12 "2013-04-11T16:05:28Z")

</div>

Looks very cool. I'll have to take a look at this.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [April 14, 2013, 7:30pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/13 "2013-04-14T19:30:44Z")

</div>

just added support for Windows x86/x64, at least I hope it’s smart enough to work on both. only tested on Windows 7 x64.  
  
For whatever reason, on Windows, tests seem to run much faster when the server is left running.

---

<div class="post-metadata">

**Author:** ![wyatt.mike\_gmail.com](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wyatt.mike_gmail.com/32/3225_2.png) [@wyatt.mike\_gmail.com](https://forums.plex.tv/u/wyatt.mike_gmail.com)\
**Post date:** [August 10, 2013, 4:14am UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/14 "2013-08-10T04:14:39Z")

</div>

Not sure if this of any interest to anyone, for kicks I tried spinning up to run the plex/nose “test suite” (if you could call it that) in a Cloud9 editor.  
  
[![7gvgkpe.png](http://i.imgur.com/7gvgkpe.png)](http://imgur.com/7gvgkpe)  
  
It took about 5 clicks and some manual extracting of the plexmediaserver.rpm, but it works dangit. And you can try channel development from any browser.

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [August 10, 2013, 6:20am UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/15 "2013-08-10T06:20:05Z")

</div>

That’s pretty sweet. I sometimes use Cloud9 at work.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 11:07pm UTC](https://forums.plex.tv/t/testing-channels-using-nose/31595/16 "2019-12-20T23:07:06Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
